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.

TMS570LC4357: SCI3 Interrupt Driven Loopback Mode

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

I am trying to setup SCI3 to be able to receive a packet of data (waiting on an 0x0A) but I am only getting one sciNotification fired.

I have read information on other threads on the forum and am following the advise but I can't get my code to work.

Can someone help please?

Using HALCoGen I have setup the following:

  • Enabled SCI3 Driver
  • Enabled VIM Channel 64: SCI3 High
  • SCI3 Global:
    • TX INT 
    • RX INT
  • SCI3 Data Format
    • 115200 Baud Rate
    • 1 Stop Bit
    • 8 Data Bits
    • No Parity Enable
    • No Even Parity
  • SCI3 Port
    • TX, RX pins in Functional Mode

My code is as follows:

#include <string.h>

#include "HL_sys_common.h"

#include "HL_sys_core.h"

#include "HL_sci.h"


uint8 rx_idx;
uint8 rx_buf[ 32 ];
uint8 tx_buf[ 32 ];


int main(void)
{

uint8 ch;

memset( &rx_buf, 0x00, sizeof( rx_buf ) );
rx_idx = 0;

memset( &tx_buf, 0xAA, sizeof( tx_buf ) - 1 );
tx_buf[ sizeof( tx_buf ) - 1 ] = 0x0A;

sciInit();

_enable_interrupt_();

sciEnableNotification( sciREG3, SCI_RX_INT );
sciEnableLoopback( sciREG3, Digital_Lbk );
sciReceive( sciREG3, 1, ( uint8 * ) &ch );

sciSend( sciREG3, 32, ( uint8 * ) &tx_buf[ 0 ] );

while ( 1 );


return 0;

}


void sciNotification( sciBASE_t *sci, uint32 flags )
{


uint8 ch;

sciReceive( sci, 1, ( uint8 * ) &ch );

if ( ch == 0x0A )
{

rx_idx = 0;

}
else
{


/* Store character in corresponding SCI Rx Buffer and post increment array index */
rx_buf[ rx_idx ]= ch;
rx_idx++;

}


}

I have attached the HALCoGen project:

1768.SCI.zip

  • Hi Jerry,

    I made, small changes to your project and now everything seems working from side.

    Here is the modified project:

    SCI_LoopBack_TEST_LC4357.zip

    Two findings from my side.

    1. First one is with your notification code.

    void sciNotification( sciBASE_t *sci, uint32 flags )
    {


    uint8 ch;

    sciReceive( sci, 1, ( uint8 * ) &ch );

    if ( ch == 0x0A )
    {

    rx_idx = 0;

    }
    else
    {


    /* Store character in corresponding SCI Rx Buffer and post increment array index */
    rx_buf[ rx_idx ]= ch;
    rx_idx++;

    }


    }

    In this notification, we already received a character and without moving that character you are initializing to receive another character.

    2. After enabling loopback we should wait till BUS was idle before transferring any data.

    So please verify my changes w.r.t to above two modifications in my attached project.

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Thank you very much, it works perfectly.

    Kind regards,

    Jerry