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.

MSPM0G3507: SPI setup for Kentec touchscreen

Part Number: MSPM0G3507
Other Parts Discussed in Thread: SYSCONFIG, BOOSTXL-K350QVG-S1

Tool/software:

I am porting GR lib to an MSPM0G3507.

I have it compiled and running sans touchscreen, but of course when I run the demo, nothing happens. It *does* appear to reset though.

I suspect my SPI settings are not correct. Before I drag out the scope, can someone check my configuration?

Here is the setup code:

eUSCI_SPI_MasterConfig spiMasterConfig =
    {
        EUSCI_B_SPI_CLOCKSOURCE_SMCLK,                      // SMCLK Clock Source
        CS_getSMCLK(),                                  // Get SMCLK frequency
        16000000,                                                // SPICLK = 16 MHz
        EUSCI_B_SPI_MSB_FIRST,                             // MSB First
        EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT,         // Phase
        EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW,         // Low polarity
        EUSCI_B_SPI_3PIN                                   // 3Wire SPI Mode
    };

    SPI_initMaster(LCD_EUSCI_MODULE, &spiMasterConfig);

    SPI_clearInterruptFlag(LCD_EUSCI_MODULE,
                           EUSCI_B_SPI_RECEIVE_INTERRUPT);

    SPI_enableModule(LCD_EUSCI_MODULE);

And here is the data transmit code:

//
    // Wait for the transmit buffer to become empty.
    //
    while(!SPI_getInterruptStatus(LCD_EUSCI_MODULE,
                                  EUSCI_B_SPI_TRANSMIT_INTERRUPT))
    {
        ;
    }

    //
    // Transmit the high byte.
    //
    SPI_transmitData(LCD_EUSCI_MODULE,ui8Data);

Here is my configuration:

  • Does the original code actually enable TXIE and RXIE, or does it just poll them? I don't see that here, and I almost never enable those for an SPI.

  • It polls them. I certainly don't see a handler. Can I poll them without enabling them? I did find my program ending up in no-handler-land.

  • Yes, the flags are set independent of the enablement (just like on the MSP430/MSP432). 

    But you do need to read the RIS (Raw Interrupt Status) not the MIS (Masked Interrupt Status). Just glancing at the source (dl_spi.h) that looks to be DL_SPI_getRawInterruptStatus().

  • Looks to me that the SysConfig is replicating the 430 configuration code.

    The interrupt section of SysConfig will enable the interrupt on the SPI's IMASK register. The interrupts have enables on the CPU (NVIC) and the peripheral level. Both would need to be enabled to enter the IRQ handler properly. If you're running into the default handler you probably have the interrupts enabled but you never created the IRQ.

    To Bruce's point, you could poll the RIS if you want to do a direct port of the code.

    Personally, I am more of a fan of using the interrupts instead of polling, but that is dependent on your application needs.

    I do see that this is running in 3-wire mode, but I would double check that your Kentec Touchscreen doesn't need a SPI CS. Are you using the BOOSTXL-K350QVG-S1?

    Regards,
    Luke

  • "Are you using the BOOSTXL-K350QVG-S1?"

    Yes. I have it working on the MSP432. I did just find that I have my Chip select screwed up somehow.

  • Sorry, found out that I was not setting the Chip Select properly.

    The graphics now works, I just need to get touch going.