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.

LAUNCHXL-F28069M: LAUNCHXL-F28069M

Part Number: LAUNCHXL-F28069M
Other Parts Discussed in Thread: C2000WARE

Hello! I'm wondering if I set up this simple UART program correctly.

All I'd like to do is receive an interrupt when I receive something, and store what I receive in an array. I'll just be receiving simple strings such as 'Go', 'Stop',  'Route 1', 'Route 2' which I will parse.

I'll be running at 9600 BAUD, half duplex (only need to receive), I don't think I need FIFO (still not entirely sure what it's for!).  

Here's what I came up with starting from an example project:

#include "DSP28x_Project.h" // Device Headerfile and Examples Include File

#define CPU_FREQ 90E6
#define LSPCLK_FREQ CPU_FREQ/4
#define SCI_FREQ 100E3
#define SCI_PRD (LSPCLK_FREQ/(SCI_FREQ*8))-1

Uint16 RXParseData[[256]; // Received data for SCI-A

void main(void)
{

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2806x_SysCtrl.c file.
InitSysCtrl();

// SET UP UART RX PIN -> function: void InitScibGpio()
EALLOW;

GpioCtrlRegs.GPAPUD.bit.GPIO19 = 0; // Enable pull-up for GPIO19 (SCIRXDB)

/* Set qualification for selected pins to asynch only */
// Inputs are synchronized to SYSCLKOUT by default.
// This will select asynch (no qualification) for the selected pins.

GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 3; // Asynch input GPIO19 (SCIRXDB)

/* Configure SCI-B pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be SCI functional pins.

GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 2; // Configure GPIO19 for SCIRXDB operation

EDIS;
// END SET UP UART RX PIN


SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol

SciaRegs.SCICTL1.all =0x0001; // enable RX, SW RESET,
// Disable TX, RX ERR, SLEEP, TXWAKE


SciaRegs.SCICTL2.bit.RXBKINTENA =1; // enable receiver interrupt

SciaRegs.SCIHBAUD = 0x0000;
SciaRegs.SCILBAUD = SCI_PRD; //9600 baud


SciaRegs.SCICTL1.all =0x0021; // Relinquish SCI from Reset

// END function


}

////////////////////////////// INTERRUPT SERVICE ROUTINE//////////////////////////  Is this the right one?

// INT9.3
__interrupt void SCIRXINTB_ISR(void)     // SCI-B
{
Uint16 i = 0;

while (i != NULL)
{
RXParseData[i]=SciaRegs.SCIRXBUF.all; // Read data
i++;
}

// To receive more interrupts from this PIE group, acknowledge this interrupt
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;

}

Thanks!

  • Hi Andrew,

    • Please use scibregs instead of sciaregs as you are using SCIB.
    • You need to add the APis related to interrupt and PIE to get the ISR to be fired and acked.
    • These 3 statements below have to be inside the rx ISR .

    SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag
    SciaRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag

    PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ack

    • Please refer to example on sci_echoback part of the c2000ware for the sci_init configurations
    • Please refer to the sci_loopback_interrupt example for the remaining framework for rx configurations .
    • Add the macro defines for SCI_PRD etc .

    Regards .

  • Hey Meghana!

    I've revised the code to address the B-regs. I understand the UART framework, but I'm not quite sure what you mean by adding the APi's for the interrupt. Isn't that done in the PIEctrl module? I definitely could be wrong though.

    Also, arent the macro definitions for SCI_PRD defined at the top?

    I did go through those two examples but I'm not quite sure what I'm missing!  I'm doing this for a school project and time is of the essence! If you'd be willing to guide me a little bit, I'd be super appreciative!

    Here's the revised code:

    #include "DSP28x_Project.h" // Device Headerfile and Examples Include File

    #define CPU_FREQ 90E6
    #define LSPCLK_FREQ CPU_FREQ/4
    #define SCI_FREQ 100E3
    #define SCI_PRD (LSPCLK_FREQ/(SCI_FREQ*8))-1

    Uint16 RXParseData[[256]; // Received data for SCI-B

    void main(void)
    {

    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the F2806x_SysCtrl.c file.
    InitSysCtrl();

    // SET UP UART RX PIN -> function: void InitScibGpio()
    EALLOW;

    GpioCtrlRegs.GPAPUD.bit.GPIO19 = 0; // Enable pull-up for GPIO19 (SCIRXDB)

    /* Set qualification for selected pins to asynch only */
    // Inputs are synchronized to SYSCLKOUT by default.
    // This will select asynch (no qualification) for the selected pins.

    GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 3; // Asynch input GPIO19 (SCIRXDB)

    /* Configure SCI-B pins using GPIO regs*/
    // This specifies which of the possible GPIO pins will be SCI functional pins.

    GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 2; // Configure GPIO19 for SCIRXDB operation

    EDIS;
    // END SET UP UART RX PIN


    ScibRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
    // No parity,8 char bits,
    // async mode, idle-line protocol

    ScibRegs.SCICTL1.all =0x0001; // enable RX, SW RESET,
    // Disable TX, RX ERR, SLEEP, TXWAKE


    ScibRegs.SCICTL2.bit.RXBKINTENA =1; // enable receiver interrupt

    ScibRegs.SCIHBAUD = 0x0000;
    ScibRegs.SCILBAUD = SCI_PRD; //9600 baud


    ScibRegs.SCICTL1.all =0x0021; // Relinquish SCI from Reset

    // END function


    }

    ////////////////////////////// INTERRUPT SERVICE ROUTINE////////////////////////// 

    // INT9.3
    __interrupt void SCIRXINTB_ISR(void) // SCI-B
    {
    Uint16 i = 0;

    while (i != NULL)
    {
    RXParseData[i]=ScibRegs.SCIRXBUF.all; // Read data
    i++;
    }

    ScibRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag
    ScibRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag

    // To receive more interrupts from this PIE group, acknowledge this interrupt

    PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;

    }

     

    • Add the macro defines for SCI_PRD etc .
  • hi Andrew,

    What i mean by adding the APi's for the interrupt is to add the apis below

    DINT;

    InitPieCtrl();

    IER = 0x0000;
    IFR = 0x0000;

    InitPieVectTable();

    Yes, It is done in the PIEctrl module. But the configuration inits have to be done in the example itself.

    Yes the macro definitions for SCI_PRD are defined at the top in the example, but it was not there in the code you shared.

    Rest of it looks fine.

    In case you see issues when run on the board let me know.

    Regards.