Part Number: MSP432P401R Tool/software: Code Composer Studio Hi, I'm using custom board with MCU as MSP432P401R . I'm trying to communicate msp432 as a master and enc424j600(ethernet) as a slave with spi connection. I found out that when spi receiver(MISO) interrupt occurs clk(P1.5) doesn't give any signal. However when transmitting data(MOSI) I can see clk signal with oscilloscope. Is there any solution or suggestion why spi reciever or clk don't work? Here comes the code!! /* * * MSP432 = SPI master, external device = SPI slave * * MSP432P401R * ----------------- * | | * | P1.4 |-> CS * | | * | P1.6 |-> Data Out (UCB0SIMO) * | | * | P1.7 | Serial Clock Out (UCB0CLK) *******************************************************************************/ const eUSCI_SPI_MasterConfig spiMasterConfig = { EUSCI_B_SPI_CLOCKSOURCE_SMCLK, // SMCLK Clock Source 24000000, 500000, 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) { /* Save the Bluetooth Stack ID. */ BluetoothStackID = (unsigned int)Result; BTPS_Delay(200); GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4); GPIO_setAsPeripheralModuleFunctionInputPin (GPIO_PORT_P1, GPIO_PIN7 | GPIO_PIN6 | GPIO_PIN5 , GPIO_PRIMARY_MODULE_FUNCTION); GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN4); GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN4); MAP_SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig); MAP_SPI_enableModule(EUSCI_B0_BASE); MAP_SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT); Interrupt_enableInterrupt(INT_EUSCIB0); MAP_Interrupt_disableInterrupt(INT_EUSCIB0); MAP_Interrupt_disableInterrupt(INT_EUSCIB0); BTPS_Delay(100); GPIO_setOutputLowOnPin(GPIO_PORT_P1,GPIO_PIN4); //while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); MAP_SPI_transmitData(EUSCI_B0_BASE, 0x22); //while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); MAP_SPI_transmitData(EUSCI_B0_BASE, 0x16); //while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); MAP_SPI_transmitData(EUSCI_B0_BASE, 0x33); //while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); MAP_SPI_transmitData(EUSCI_B0_BASE, 0x31); GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN4); BTPS_Delay(1); GPIO_setOutputLowOnPin(GPIO_PORT_P1,GPIO_PIN4); //while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); MAP_SPI_transmitData(EUSCI_B0_BASE, 0x20); //while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT))); MAP_SPI_transmitData(EUSCI_B0_BASE, 0x16); BTPS_Delay(1); while (MAP_GPIO_getInputPinValue(GPIO_PORT_P1, GPIO_PIN7)); Interrupt_enableInterrupt(INT_EUSCIB0); GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN4); Display(("%d \r\n",a)); /* 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); } } void EUSCIB0_IRQHandler(void) { //GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4); uint32_t status = SPI_getEnabledInterruptStatus(EUSCI_B0_BASE); SPI_clearInterruptFlag(EUSCI_B0_BASE, status); if(status & EUSCI_B_SPI_RECEIVE_INTERRUPT) { /* USCI_B0 TX buffer ready? */ while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT))); RXData = MAP_SPI_receiveData(EUSCI_B0_BASE); Display(("RXData = %x\r\n",RXData)); //BTPS_Delay(10); //GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4); } }
↧