This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28069M: Clock Signal Not Present on SPI SCLKA

Part Number: TMS320F28069M


Hi all,

I am trying to use my F28069M LaunchPad to read data from an ADC using SPI_A. I have set up the module using the Control Suite example as a starting point and making changes based on the datasheet. I have not yet gone as far as trying to interpret the incoming data, I am just trying to check that a clock is being produced using my oscilloscope. The pin that I expect the clock to be visible on is permanently at logic high whereas I'm expecting to see a clock of approximately 1.6MHz.

My GPIO initialisation code is as follows:

//--- Group B pins
	GpioCtrlRegs.GPBCTRL.all  = 0x00000000;		// QUALPRD = SYSCLKOUT for all group B GPIO
	GpioCtrlRegs.GPBQSEL1.all = 0x00000000;		// No qualification for all group B GPIO 32-44
	GpioCtrlRegs.GPBQSEL2.all = 0x00000000;		// No qualification for all group B GPIO 50-58
	GpioCtrlRegs.GPBDIR.all   = 0x00000000;		// All group B GPIO are inputs
	GpioCtrlRegs.GPBPUD.all   = 0x00000000;		// All group B pullups enabled

    GpioCtrlRegs.GPBDIR.bit.GPIO56   = 1;     // Set GPIO56 to output direction

	GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 0;		// 0=GPIO               1=SDAA      2=EPWMSYNCI  3=ADCSOCAO
	GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 0;		// 0=GPIO               1=SCLA      2=EPWMSYNCO  3=ADCSOCBO
	GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;		// 0=GPIO               1=COMP2OUT  2=rsvd       3=COMP3OUT
	GpioCtrlRegs.GPBMUX1.bit.GPIO35 = 0;		// 0=GPIO (TDI)         1=rsvd      2=rsvd       3=rsvd
	GpioCtrlRegs.GPBMUX1.bit.GPIO36 = 0;		// 0=GPIO (TMS)         1=rsvd      2=rsvd       3=rsvd
	GpioCtrlRegs.GPBMUX1.bit.GPIO37 = 0;		// 0=GPIO (TDO)         1=rsvd      2=rsvd       3=rsvd
	GpioCtrlRegs.GPBMUX1.bit.GPIO38 = 0;		// 0=GPIO/XCLKIN (TCK)  1=rsvd      2=rsvd       3=rsvd
	GpioCtrlRegs.GPBMUX1.bit.GPIO39 = 0;		// 0=GPIO               1=rsvd      2=rsvd       3=rsvd
	GpioCtrlRegs.GPBMUX1.bit.GPIO40 = 0;		// 0=GPIO               1=EPWM7A    2=SCITXDB    3=rsvd
	GpioCtrlRegs.GPBMUX1.bit.GPIO41 = 0;		// 0=GPIO               1=EPWM7B    2=SCIRXDB    3=rsvd
	GpioCtrlRegs.GPBMUX1.bit.GPIO42 = 0;		// 0=GPIO               1=EPWM8A    2=TZ1        3=COMP1OUT
	GpioCtrlRegs.GPBMUX1.bit.GPIO43 = 0;		// 0=GPIO               1=EPWM8B    2=TZ2        3=COMP2OUT
	GpioCtrlRegs.GPBMUX1.bit.GPIO44 = 0;		// 0=GPIO               1=MFSRA     2=SCIRXDB    3=EPWM7B

	GpioCtrlRegs.GPBMUX2.bit.GPIO50 = 0;		// 0=GPIO               1=EQEP1A    2=MDXA       3=TZ1
	GpioCtrlRegs.GPBMUX2.bit.GPIO51 = 0;		// 0=GPIO               1=EQEP1B    2=MDRA       3=TZ2
	GpioCtrlRegs.GPBMUX2.bit.GPIO52 = 0;		// 0=GPIO               1=EQEP1S    2=MCLKXA     3=TZ3
	GpioCtrlRegs.GPBMUX2.bit.GPIO53 = 0;		// 0=GPIO               1=EQEP1I    2=MFSXA      3=rsvd
	GpioCtrlRegs.GPBMUX2.bit.GPIO54 = 0;		// 0=GPIO               1=SPISIMOA  2=EQEP2A     3=HRCAP1
	GpioCtrlRegs.GPBMUX2.bit.GPIO55 = 0;		// 0=GPIO               1=SPISOMIA  2=EQEP2B     3=HRCAP2
	GpioCtrlRegs.GPBMUX2.bit.GPIO56 = 1;		// 0=GPIO               1=SPICLKA   2=EQEP2I     3=HRCAP3
	GpioCtrlRegs.GPBMUX2.bit.GPIO57 = 0;		// 0=GPIO               1=SPISTEA   2=EQEP2S     3=HRCAP4
	GpioCtrlRegs.GPBMUX2.bit.GPIO58 = 0;		// 0=GPIO               1=MCLKRA    2=SCITXDB    3=EPWM7A

And my SPI module initialisation code...

void InitSPI(void) //Initialises the SPI modules on the F2806x
{
    SpiaRegs.SPICCR.bit.SPISWRESET=0;   // Reset SPI
    SpiaRegs.SPICCR.all=0x004F;         // Active LOW clock, 16 bit characters
    SpiaRegs.SPICTL.all=0x0007;         // SPI Master Mode, Enable Transmission, Enable Interrupts
    SpiaRegs.SPISTS.all=0x0000;         // Clear the status register, resetting all flags.
    SpiaRegs.SPIBRR=0x001B;             // Set the Baud Rate to around 1.6Mbps

    SpiaRegs.SPIFFTX.bit.SPIFFENA=0;    // Disable Tx  FIFO enhancements
    SpiaRegs.SPIFFRX.bit.RXFFIENA=0;    // Disable Rx FIFO interrupts
    SpiaRegs.SPIFFCT.all=0x00;
    SpiaRegs.SPIPRI.bit.TRIWIRE=0;      //Disable three wire mode for standard 4 wire SPI

    SpiaRegs.SPICCR.bit.SPISWRESET=1;   // Enable SPI
}

I have used the debugger on CCS to verify that both of these pieces of code are being executed but there is still no sign of the clock signal on the pin.

Any ideas what's wrong?

  • Euan,

    Just checking, is there an EALLOW directly before changing the GPIO control registers for the SPI pins?
    Another note, setting the GPIO direction does not matter if you then set the pin to a peripheral function. the peripheral function takes precedence, so the GPIO direction (as set by GPxDIR) does not matter.

    Please tell me if the following assumptions are incorrect:
    You expect that after setting the GPIO mux settings (as in your first code snippet) and then executing the InitSPI function, the SPICLK will immediately begin toggling. This will not happen as the SPI only toggles its clock if there is an active transmission. In order to see the clock toggle you will need to transmit some data. Now, if I am correct in your assumption great. If not, please, let me know.

    Have you also verified that the SPI is in fact set up? did you enable the peripheral clock? if you are using example code provided by TI, I think that you are likely calling the InitSysCtrl() function which does initialize all peripheral clocks, but please verify that this is occurring as well.

    Let me know if any of these help.

    Thanks,
    Mark
  • In answer to your questions:
    1) I am using example code from TI to initialise the GPIO pins, and I can confirm that EALLOW has been used above the code snippet that I posted.
    2) I had tried the code without setting the pin direction. I thought that it wouldn't make a difference so I tried the code without it first. I only added it to see if it changed anything.
    3) I did indeed expect the clock to start toggling as soon as I called the InitSPI function. I am using the F28069 as a master to receive measurements from an AD7476 ADC. This chip returns its conversion result as soon as the clock is applied and "chip select" is pulled low. Therefore I have no need to transmit anything from the master to the slave, but I do need the master to be generating a clock signal so that the ADC can shift out its data at the correct baud rate.
    4) You are correct that I am calling the InitSysCtrl() function which enables the clock to SPIA by default. I have not changed this file in any way.

    My overall logic here was that the SPI clock would run all the time, I would trigger the ADC to start a conversion by pulling CS low using a GPIO then an SPI Rx Interrupt would be triggered by the arrival of the 16th bit of the conversion result. Perhaps you could advise if this approach is flawed?
  • Euan,

    Thanks for the clarification. Your Configuration then appears to be correct, but your understanding of the SPI is slightly flawed. As I mentioned the SPICLK will not toggle until an active transmission occurs. A master always initiates a transfer, and only then will clocks toggle. Please read into the SPI Chapter of the TRM for the F28069. Specifically the Introduction to Operation section as well as the Master Mode section. This covers how you should expect the SPI module to operate at a basic level. Generally for SPI, you can reference the Wikipedia page for the SPI protocol as well. Its pretty decent. 

    In any case to help you solve your problem you need the master to initiate the transfer. The master accomplishes this by transmitting a dummy word with the length of the word you are reading from the slave. you mentioned it was 16 bits, so you can just "transmit" a 16-bit word and read the result from the SPIRXBUF after the word has completed sending. you can detect this with the SPIINT FLAG if not using FIFO, or with the RXFIFO interrupt. You can think of this as the master "clocking out" the slave word. 

    Regards,
    Mark

  • Thanks for your reply Mark. I will review the SPI section of the TRM to see if I can better understand how it works. I hadn't thought to transmit a dummy word to trigger the conversion but I will look into this.