Other Parts Discussed in Thread: MSP430FR5989, MSP430FR5969
Tool/software: Code Composer Studio
I have a circuit with MSP430FR5989 and need to activate 3 SPI module UCBA1, UCB0, UCB1. Started to test UCB0 and UCB1 with pins as follows: UCB0: P1.4, P1.6, P1.7 and UCB1: P3.0 , P3.1, P3.2
The code I have tested is as below. When I run the code I check the pins on oscilloscope and there is no clk signal on CLK pin and no data on SIMO pin (I have checked other pins too)
I have test same code on TI development board with MCU MSP430FR5969. I only change this line for corresponding pins (P2.2, P1.6, P1.7). It works fine on development board. One time I forgot to change P2.2 as clock but it was still working fine with MOSI pin on lauchpad.
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P1,
GPIO_PIN4 + GPIO_PIN6 + GPIO_PIN7,
GPIO_SECONDARY_MODULE_FUNCTION
);
I have checked UCBA1 and CS(clock system) registers on CCS debugger and they are both identical for those 2 MCUs. I cannot see any difference with the registers
I have tested UCB0 as I2C on pins P1.6 and P1.7 and it has the same result with no activity on pins.
I have also tested P1.4, P1.6 and P1.7 pins as GPIO output and toogle them with some delay. I can clearly see the activity on oscilloscope. I am sure that chip is soldered well and measuring points are connected to chip.
When I set pins as GPIO they are ok but I cannot set them as SPI or I2C. Please help to solve the issue.
#include <msp430.h> #include <driverlib.h> //#include "I2CMaster.h" uint8_t TXData; uint8_t RXData; void delayMs(int ms){ int i; while(ms--){ i = 1000; while(i--); } } int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer //Set DCO frequency to max DCO setting CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_6); // dco @8mhz // CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_3); //Select DCO as the clock source for SMCLK with no frequency divider CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); //GPIO test init // GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN4|GPIO_PIN6| GPIO_PIN7); GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_P1, GPIO_PIN4 + GPIO_PIN6 + GPIO_PIN7, GPIO_SECONDARY_MODULE_FUNCTION ); PMM_unlockLPM5(); // // //Initialize Master EUSCI_B_SPI_initMasterParam param = {0}; param.selectClockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK; param.clockSourceFrequency = CS_getSMCLK(); param.desiredSpiClock = 500000; param.msbFirst = EUSCI_B_SPI_MSB_FIRST; param.clockPhase = EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT; param.clockPolarity = EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH; param.spiMode = EUSCI_B_SPI_3PIN; EUSCI_B_SPI_initMaster(EUSCI_B0_BASE, ¶m); EUSCI_B_SPI_enable(EUSCI_B0_BASE); EUSCI_B_SPI_clearInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT); // Enable USCI_B0 RX interrupt EUSCI_B_SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT); __delay_cycles(200); TXData = 0x55; // Holds TX data while(1){ while (!EUSCI_B_SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)) ; //Transmit Data to slave EUSCI_B_SPI_transmitData(EUSCI_B0_BASE, TXData); GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0); // GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN4 + GPIO_PIN6 + GPIO_PIN7); delayMs(50); GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0); // GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN4 + GPIO_PIN6 + GPIO_PIN7); delayMs(50); } return 0; } __attribute__((interrupt(USCI_B0_VECTOR))) void USCI_B0_ISR (void) { switch (__even_in_range(UCB0IV, USCI_SPI_UCTXIFG)) { case USCI_SPI_UCRXIFG: // UCRXIFG //USCI_B0 TX buffer ready? while (!EUSCI_B_SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)); RXData = EUSCI_B_SPI_receiveData(EUSCI_B0_BASE); //Increment data // TXData++; //Send next value // EUSCI_B_SPI_transmitData(EUSCI_B0_BASE, // TXData // ); //Delay between transmissions for slave to process information __delay_cycles(40); break; default: break; } }