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.

28335 SCI - transmit receive interrupt issue

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I am using 28335 for SCI-A communication. I am able to get the first transmit interrupt, but later on i am not getting next interrupt for transmission of the next words in my buffer,.
Similarly, i am not getting any interrupt for reception. Please tell me what wrong am i doing.

My code -


/***************************************************************************************/
/* Imported header files: */

#include "DSP2833x_CpuTimers.h"
#include "scidrv.h"


#define BAUD_RATE_115200    115200
#define BAUD_RATE_9600      9600
#define MAX_SCIBUF_SIZE     256
#define LSPCLOCK            75000000

scidrv_txPacket_st scidrv_txPacket;
char *msgTxPtr_chp;
uint16_t msgFlag_u16 = 0;
static uint16_t wrIndx_u16s = 0;
static uint16_t rdIndx_u16s = 0;

static uint16_t readBuff_u16s[MAX_SCIBUF_SIZE];
static uint16_t writBuff_u16s[MAX_SCIBUF_SIZE];

/* Local Function Defines */
void scidrv_InitSci_vd(void);
static void scidrv_InitSciA_vd(void);
static void SetBaudRate_vds(uint16_t interface_u16,uint32_t sciBaudRt_u32);
static void scidrv_InitSciAGpio_vd(void);
static uint16_t HexToAscii(uint16_t hexValue_u16);


/*--------------------------------------------------------------------------------------*/
/*!@brief     scidrv_InitSci_vd:Initializes the SCI A  module for communication
 ---------------------------------------------------------------------------------------*/
void scidrv_InitSci_vd(void)
{
    uint16_t index_u16 = 0;

    /* Initialize the write buffer with data that has to be written to the SCI A*/
    for(index_u16 = 0; index_u16 < MAX_SCIBUF_SIZE; index_u16++)
    {
        /* Initialize the write buffer with data that has to be written to the SCI A*/
        writBuff_u16s[index_u16] = MAX_SCIBUF_SIZE - index_u16;
        /* Initialize the read buffer with zero*/
        readBuff_u16s[index_u16] = 0;
    }

    scidrv_InitSciA_vd();

    EALLOW;
    DINT;
    PieVectTable.SCIRXINTA = &scidrv_ReceiveAIsr_vd;
    PieVectTable.SCITXINTA = &scidrv_TransmitAIsr_vd;

    EINT;       // Enable CPU interrupt
    EDIS;

}


/*-------------------------------------------------------------------------------------*/
/*!@brief         scidrv_InitSciA_vd:This function initializes the SCI A module.
 *-------------------------------------------------------------------------------------*/
void scidrv_InitSciA_vd(void)
{
    EALLOW;

    /* Initialize SCI-A for Debug interface */
    /* Note: Clocks were turned on to the SCIA peripheral */
    /* in the InitSysCtrl() function */

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

    /* enable TX, RX, internal SCICLK,*/
    /* Disable RX ERR, SLEEP, TXWAKE*/
    SciaRegs.SCICTL1.all = 0x0003;

    SciaRegs.SCICTL2.all = 0x0003;
    SciaRegs.SCICTL2.bit.TXINTENA = 1;   /*Enable TX interrupt*/
    SciaRegs.SCICTL2.bit.RXBKINTENA = 1; /*Enable RX interrupt*/

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

    /* Added Function for Setting Baud rate for SCI-A*/
    SetBaudRate_vds(SCIA, BAUD_RATE_115200);

    /* Enable interrupts required for this example*/
    PieCtrlRegs.PIEIER9.bit.INTx1=1;     /* PIE Group 9, int1*/
    PieCtrlRegs.PIEIER9.bit.INTx2=1;     /* PIE Group 9, INT2*/

    /* Enable interrupts required for SCI */
    IER  |= PIEACK_GROUP9;

    EDIS;

    scidrv_InitSciAGpio_vd();
}


/*-------------------------------------------------------------------------------------*/
/*!@brief         SetBaudRate_svd:This function Sets Baud Rate for SCI Driver.
 *-------------------------------------------------------------------------------------*/
static void SetBaudRate_vds(uint16_t interface_u16, uint32_t sciBaudRt_u32)
{
    uint16_t brrDecVal_u16 = INIT_VAL;
    brrDecVal_u16 = (LSPCLOCK/(sciBaudRt_u32 * EIGHT)) - ONE;

    switch(interface_u16)
    {
    case SCIA:
        SciaRegs.SCIHBAUD =  (brrDecVal_u16 & 0xFF00) >> EIGHT_BIT;
        SciaRegs.SCILBAUD =  (brrDecVal_u16 & 0x00FF);
        break;
    case SCIB:
        ScibRegs.SCIHBAUD =  (brrDecVal_u16 & 0xFF00) >> EIGHT_BIT;
        ScibRegs.SCILBAUD =  (brrDecVal_u16 & 0x00FF);
        break;
    case SCIC:
        ScicRegs.SCIHBAUD =  (brrDecVal_u16 & 0xFF00) >> EIGHT_BIT;
        ScicRegs.SCILBAUD =  (brrDecVal_u16 & 0x00FF);
        break;
    default:
        /* 2400 ~ 9600 bps */
        /* 4801 ~ 9600 bps */
        /* 9603 ~ 9600 bps */
        /* 19230 ~ 9600 bps */
        /* 38461 ~ 9600 bps */
        /* 115384 ~ 115200 bps */
        break;
    }
    return;
}


/*-------------------------------------------------------------------------------------*/
/*!@brief         scidrv_InitSciAGpio_vd:This function initializes GPIO pins to
                  function as SCI-A pins
 *-------------------------------------------------------------------------------------*/
void scidrv_InitSciAGpio_vd()
{
    EALLOW;

    /* Enable internal pull-up for the selected pins */
    /* Pull-ups can be enabled or disabled disabled by the user. */
    /* This will enable the pull-ups for the specified pins. */

    GpioCtrlRegs.GPAPUD.bit.GPIO28 = SCI_PULLUP_EN; // Enable pull-up for GPIO28(SCIRXDA)
    GpioCtrlRegs.GPAPUD.bit.GPIO29 = SCI_PULLUP_EN; // Enable pull-up for GPIO29(SCITXDA)

    GpioCtrlRegs.GPADIR.bit.GPIO28 = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO29 = 1;

    /* 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.GPIO28 = SCI_GPIO_ASYNC;  // Asynch input GPIO28 (SCIRXDA)
    GpioCtrlRegs.GPAQSEL2.bit.GPIO29 = SCI_GPIO_ASYNC;  // Asynch input GPIO29 (SCITXDA)

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

    GpioCtrlRegs.GPAMUX2.bit.GPIO28 = SCIA_EN;   // Configure GPIO28 for SCIRXDA operation
    GpioCtrlRegs.GPAMUX2.bit.GPIO29 = SCIA_EN;   // Configure GPIO29 for SCITXDA operation

    EDIS;
}


/*--------------------------------------------------------------------------------------*/
/*!@brief     test_SciADebugPort_vd:
 ---------------------------------------------------------------------------------------*/
void test_SciADebugPort_bool(void)
{
    /* Write the data  from write buffer to SCI*/
    scidrv_transmit_vd(writBuff_u16s, MAX_SCIBUF_SIZE);
}


/*--------------------------------------------------------------------------------------*/
/*!@brief     scidrv_TransmitAIsr_vd:Interrupt Service Routine for SCI-A transmission
 ---------------------------------------------------------------------------------------*/
void scidrv_TransmitAIsr_vd(void)
{
    if(MAX_SCIBUF_SIZE > wrIndx_u16s)
    {
        // xmit MSB
        SciaRegs.SCITXBUF = (HexToAscii(writBuff_u16s[++wrIndx_u16s] & 0xFF00) >> 8);

        // xmit LSB
        SciaRegs.SCITXBUF = (HexToAscii(writBuff_u16s[wrIndx_u16s] & 0x00FF));

        EALLOW;
//        SciaRegs.SCICTL2.bit.TXINTENA = 1;
        SciaRegs.SCICCR.all = 0x0007;
        SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
    }
    else
    {
        wrIndx_u16s = 0;

        EALLOW;
        SciaRegs.SCICTL2.bit.TXINTENA = 0;
        SciaRegs.SCICTL1.bit.TXENA = 0;
    }

    PieCtrlRegs.PIEACK.all |= PIEACK_GROUP9;          // Issue PIE ACK
    EDIS;
}


/*--------------------------------------------------------------------------------------*/
/*!@brief     scidrv_ReceiveAIsr_vd:Interrupt Service Routine for SCI-A transmission
 ---------------------------------------------------------------------------------------*/
void scidrv_ReceiveAIsr_vd(void)
{
    uint16_t cmdByteRec_u16;
    cmdByteRec_u16 = SciaRegs.SCIRXBUF.all;

    readBuff_u16s[rdIndx_u16s] = cmdByteRec_u16;

    if(rdIndx_u16s >= MAX_SCIBUF_SIZE)
        rdIndx_u16s = 0;

    if(((cmdByteRec_u16 != 255) && (cmdByteRec_u16 != 10)))
    {
        // MBX_post(&mbxdiag, &cmdByteRec_u16,0);
    }

    EALLOW;
    /* Ack the Reception Interrupt*/
    PieCtrlRegs.PIEACK.all |= PIEACK_GROUP9;         // Issue PIE ack
    EDIS;
}


/*--------------------------------------------------------------------------------------*/
/*!@brief          This routine will extract the command from the command buffer and
 *                 form a string.
  ---------------------------------------------------------------------------------------*/
void scidrv_transmit_vd(uint16_t *txDataptr_u16p, uint16_t length_u16)
{
    uint16_t txData;

    EALLOW;
    //    SciaRegs.SCICTL2.bit.TXINTENA = 1;
        SciaRegs.SCICTL1.bit.TXENA = 1;
    EDIS;

    /* Set the message flag to 0 indicating the digit data is sent to terminal*/
    msgFlag_u16 = 0;

    /*Update the transmission data pointer and length */
    scidrv_txPacket.dataPtr_u16p = txDataptr_u16p;
    scidrv_txPacket.len_u16 = length_u16;

    /* send one byte of data to initiate the data transmission*/
    /* get the last nibble of the data*/
    // txData = (((*txDataptr_u16p) & 0xF000) >> 12);
    // txData = *txDataptr_u16p;

    txData = (((*txDataptr_u16p) & 0xFF00) >> 8);

    txData = 0x0061;

    /* convert the digit to its ascii*/
//    txData = HexToAscii(txData);

    /* load the tx buffer*/
    SciaRegs.SCITXBUF = txData;

    GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;

    return;
}


/*--------------------------------------------------------------------------------------*/
/*!@brief     HextoAscii conversion:Convetrs a hex character to its equivalent ASCII
 ---------------------------------------------------------------------------------------*/
uint16_t HexToAscii(uint16_t hexValue_u16)
{
    uint16_t asciiValue;
    if(hexValue_u16 >= 0x0A)
    {
        asciiValue = hexValue_u16 - 0x0A;
        asciiValue = asciiValue + 'A';
    }
    else
    {
        asciiValue = hexValue_u16 + '0';
    }
    return asciiValue;
}

//===========================================================================
// End of file.
//===========================================================================

 

Please help with appropiate suggestions.

Arpan