Tool/software: Code Composer Studio Hi, I'm trying to use spi on SPPDemo example. I've checked Serial Clock Source with Oscilloscope. No output comes out on pin I've customized. So I've made new project using only spi and it seems to be working since confirmation of checking output clock source by scope on pin. I've attached 2 source code. First one is spi implemented on SPPDemo sample example. Second one is new project using only spi. I wonder why spi clk doesn't work on SPPDemo with my code. Can you please help me out? Connection information * MSP432 = SPI master, external device = SPI slave * * MSP432P401 * ----------------- * | | * | P1.4 |-> CS * | | * | P1.6 |-> Data Out (UCB0SIMO) * | | * | P1.7 | Serial Clock Out (UCB0CLK) *******************************************************************************/ ※main.c(sppdemo) const eUSCI_SPI_MasterConfig spiMasterConfig = { EUSCI_B_SPI_CLOCKSOURCE_SMCLK, 24000000, 4000000, EUSCI_B_SPI_MSB_FIRST, EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH, EUSCI_B_SPI_3PIN }; int main(void) { int Result; uint16_t Result1; BTPS_Initialization_t BTPS_Initialization; HCI_DriverInformation_t HCI_DriverInformation; HCI_HCILLConfiguration_t HCILLConfig; HCI_Driver_Reconfigure_Data_t DriverReconfigureData; /* Configure the hardware for its intended use. */ HAL_ConfigureHardware(); /* Flag that sleep is not currently enabled. */ SleepAllowed = FALSE; /* Configure the UART Parameters. */ HCI_DRIVER_SET_COMM_INFORMATION(&HCI_DriverInformation, 1, HAL_HCI_UART_MAX_BAUD_RATE, cpHCILL_RTS_CTS); HCI_DriverInformation.DriverInformation.COMMDriverInformation.InitializationDelay = 100; /* Set up the application callbacks. */ BTPS_Initialization.GetTickCountCallback = HAL_GetTickCount; BTPS_Initialization.MessageOutputCallback = HAL_ConsoleWrite; /* Initialize the application. */ if((Result = InitializeApplication(&HCI_DriverInformation, &BTPS_Initialization)) > 0) { //added here GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN4); GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION); SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig); SPI_enableModule(EUSCI_B0_BASE); SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT); //Interrupt_enableInterrupt(INT_EUSCIB0); /* Save the Bluetooth Stack ID. */ BluetoothStackID = (unsigned int)Result; BTPS_Delay(2000); //Eth_init(); /* Register a sleep mode callback if we are using HCILL Mode. */ if((HCI_DriverInformation.DriverInformation.COMMDriverInformation.Protocol == cpHCILL) || (HCI_DriverInformation.DriverInformation.COMMDriverInformation.Protocol == cpHCILL_RTS_CTS)) { HCILLConfig.SleepCallbackFunction = HCI_Sleep_Callback; HCILLConfig.SleepCallbackParameter = 0; DriverReconfigureData.ReconfigureCommand = HCI_COMM_DRIVER_RECONFIGURE_DATA_COMMAND_CHANGE_HCILL_PARAMETERS; DriverReconfigureData.ReconfigureData = (void *)&HCILLConfig; /* Register the sleep mode callback. Note that if this */ /* function returns greater than 0 then sleep is currently */ /* enabled. */ Result = HCI_Reconfigure_Driver(BluetoothStackID, FALSE, &DriverReconfigureData); if(Result > 0) { Display(("Sleep is allowed.\r\n")); /* Flag that it is safe to go into sleep mode. */ SleepAllowed = TRUE; } } BTPS_Delay(1000); GPIO_setOutputLowOnPin(GPIO_PORT_P1,GPIO_PIN4); BTPS_Delay(1); while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); SPI_transmitData(EUSCI_B0_BASE, 0x20); while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); SPI_transmitData(EUSCI_B0_BASE, 0x16); GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN4); BTPS_Delay(10); uint16_t retT; retT = SPI_receiveData(EUSCI_B0_BASE); retT = (retT << 8) | SPI_receiveData(EUSCI_B0_BASE); Display(("retT: %x\r\n",retT)); BTPS_Delay(1000); GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN4); /* We need to execute Add a function to process the command line */ /* to the BTPS Scheduler. */ if(BTPS_AddFunctionToScheduler(ProcessCharactersTask, NULL, 100)) { /* Add the idle task (which determines if LPM3 may be entered) */ /* to the scheduler. */ if(BTPS_AddFunctionToScheduler(IdleTask, NULL, 100)) { if(BTPS_AddFunctionToScheduler(ToggleLEDTask, NULL, 750)) { HAL_SetLEDColor(hlcGreen); /* Execute the scheduler, note that this function does */ /* not return. */ BTPS_ExecuteScheduler(); } } } } /* If we've gotten to this point then an error has occurred, set the */ /* LED to red to signify that there is a problem. */ HAL_SetLEDColor(hlcRed); /* Poll the error flags to see if we can determine the reason for the*/ /* failure. */ PollErrorFlags(); /* Scheduler above should run continuously, if it exits an error */ /* occurred. */ while(1) { HAL_ToggleLED(); BTPS_Delay(100); } } ※main.c(spi) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ code start const eUSCI_SPI_MasterConfig spiMasterConfig = { EUSCI_B_SPI_CLOCKSOURCE_SMCLK, 24000000, 4000000, EUSCI_B_SPI_MSB_FIRST, EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH, EUSCI_B_SPI_3PIN }; inline void chip_select() { GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4); } inline void chip_deselect() { GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4); } void main(void) { uint16_t ii; uint16_t RXData_a; WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //CLK configure GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION); CS_setExternalClockSourceFrequency(0, HFXTCLK_FREQUENCY); PCM_setCoreVoltageLevel(PCM_VCORE1); FlashCtl_setWaitState(FLASH_BANK0, 2); FlashCtl_setWaitState(FLASH_BANK1, 2); CS_initClockSignal(CS_MCLK, MCLK_SOURCE, CONCAT(CS_CLOCK_DIVIDER_,MCLK_DIVIDER)); CS_initClockSignal(CS_HSMCLK, HSMCLK_SOURCE, CONCAT(CS_CLOCK_DIVIDER_,HSMCLK_DIVIDER)); CS_initClockSignal(CS_SMCLK, SMCLK_SOURCE, CS_CLOCK_DIVIDER_2); CS_startHFXT(false); //SPI configure chip_deselect(); GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN4); GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION); SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig); SPI_enableModule(EUSCI_B0_BASE); SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT); //Interrupt_enableInterrupt(INT_EUSCIB0); while(1) { chip_select(); TXData = 0x20; while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); SPI_transmitData(EUSCI_B0_BASE, TXData); TXData = 0x16; B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); SPI_transmitData(EUSCI_B0_BASE, TXData); RXData = SPI_receiveData(EUSCI_B0_BASE); RXData_a = (RXData << 8) | SPI_receiveData(EUSCI_B0_BASE); for(ii=0; ii<10; ii++); chip_deselect(); } } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
↧