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.

  • Resolved

F28377D SCI BaudRate

Prodigy 240 points

Replies: 15

Views: 4334

Hi , this is my first post in TI forums .


I am using Delfino F2837x Control Card R1.1 and Docking Station R4.1 , I have installed CCS6.1 and controlSuite , I have a problem using sample code of sci_echoback_cpu01 , I built it and then pressed debug key in ccs , everything is ok , but I received unrecognized words in hyperterminal instead Hello World! and other messages .

I think that it should be baudrate problem , but I did not changed anything , it's all default codes .

here is my code :

//###########################################################################
// FILE:    Example_28X7xSci_Echoback.c
// TITLE:   SCI Echoback.
//
//! \addtogroup cpu01_example_list
//! <h1>SCI Echoback</h1>
//!
//!  This test receives and echo-backs data through the SCI-A port.
//!
//!  The PC application 'hypterterminal' can be used to view the data
//!  from the SCI and to send information to the SCI.  Characters received
//!  by the SCI port are sent back to the host.
//!
//!  \b Running \b the \b Application
//!  -# Configure hyperterminal:
//!  Use the included hyperterminal configuration file SCI_96.ht.
//!  To load this configuration in hyperterminal
//!    -# Open hyperterminal
//!    -# Go to file->open
//!    -# Browse to the location of the project and
//!       select the SCI_96.ht file.
//!  -# Check the COM port.
//!  The configuration file is currently setup for COM1.
//!  If this is not correct, disconnect (Call->Disconnect)
//!  Open the File-Properties dialog and select the correct COM port.
//!  -# Connect hyperterminal Call->Call
//!  and then start the 2806x SCI echoback program execution.
//!  -# The program will print out a greeting and then ask you to
//!  enter a character which it will echo back to hyperterminal.
//!
//!  \note If you are unable to open the .ht file, you can create
//!  a new one with the following settings
//!  -  Find correct COM port
//!  -  Bits per second = 9600
//!  -  Date Bits = 8
//!  -  Parity = None
//!  -  Stop Bits = 1
//!  -  Hardware Control = None
//!
//!  \b Watch \b Variables \n
//!  - \b LoopCount, for the number of characters sent
//!  - ErrorCount
//!
//! \b External \b Connections \n
//!  Connect the SCI-A port to a PC via a transceiver and cable.
//!  - GPIO28 is SCI_A-RXD (Connect to Pin3, PC-TX, of serial DB9 cable)
//!  - GPIO29 is SCI_A-TXD (Connect to Pin2, PC-RX, of serial DB9 cable)
//
//###########################################################################
// $TI Release: F2837xD Support Library v110 $
// $Release Date: Mon Apr  7 10:35:37 CDT 2014 $
//###########################################################################

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

// Prototype statements for functions found within this file.
void scia_echoback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void scia_msg(char *msg);

// Global counts used in this example
Uint16 LoopCount;
Uint16 ErrorCount;

void main(void)
{

   Uint16 ReceivedChar;
   char *msg;

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

// Step 2. Initialize GPIO:
// This example function is found in the F2837xD_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
   InitGpio();

// For this example, only init the pins for the SCI-A port.
// These functions are found in the F2837xD_Gpio.c file.
   GPIO_SetupPinMux(28, GPIO_MUX_CPU1, 1);
   GPIO_SetupPinOptions(28, GPIO_INPUT, GPIO_PUSHPULL);
   GPIO_SetupPinMux(29, GPIO_MUX_CPU1, 1);
   GPIO_SetupPinOptions(29, GPIO_OUTPUT, GPIO_PUSHPULL);

// Step 3. Clear all __interrupts and initialize PIE vector table:
// Disable CPU __interrupts
   DINT;

// Initialize PIE control registers to their default state.
// The default state is all PIE __interrupts disabled and flags
// are cleared.
// This function is found in the F2837xD_PieCtrl.c file.
   InitPieCtrl();

// Disable CPU __interrupts and clear all CPU __interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the __interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in F2837xD_DefaultIsr.c.
// This function is found in F2837xD_PieVect.c.
   InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:
// This function is found in F2837xD_InitPeripherals.c
// InitPeripherals(); // Not required for this example

// Step 5. User specific code:

    LoopCount = 0;
    ErrorCount = 0;

    scia_fifo_init();       // Initialize the SCI FIFO
    scia_echoback_init();  // Initialize SCI for echoback

    msg = ":Hello World!;";
    scia_msg(msg);

    msg = ":You will enter a character, and the DSP will echo it back!;";
    scia_msg(msg);

    for(;;)
    {
       msg = ":Enter a character;";
       scia_msg(msg);

       // Wait for inc character
       while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for XRDY =1 for empty state

       // Get character
       ReceivedChar = SciaRegs.SCIRXBUF.all;

       // Echo character back
       msg = ":You sent ;";
       scia_msg(msg);
       scia_xmit(ReceivedChar);

       LoopCount++;
    }
}

// Test 1,SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void scia_echoback_init()
{
    // Note: Clocks were turned on to the SCIA peripheral
    // in the InitSysCtrl() function

     SciaRegs.SCICCR.all = 0x0007;   // 1 stop bit,  No loopback
                                   // No parity,8 char bits,
                                   // async mode, idle-line protocol
    SciaRegs.SCICTL1.all = 0x0003;  // enable TX, RX, internal SCICLK,
                                   // Disable RX ERR, SLEEP, TXWAKE
    SciaRegs.SCICTL2.all = 0x0003;
    SciaRegs.SCICTL2.bit.TXINTENA = 1;
    SciaRegs.SCICTL2.bit.RXBKINTENA = 1;

//    SciaRegs.SCIHBAUD    =0x0002;  // 9600 baud @LSPCLK = 50MHz (200 MHz SYSCLK).
//  SciaRegs.SCILBAUD    =0x008B;

    SciaRegs.SCIHBAUD    = 0x0002;  // 9600 baud @LSPCLK = 50MHz (200 MHz SYSCLK).
    SciaRegs.SCILBAUD    = 0x008B;

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

// Transmit a character from the SCI
void scia_xmit(int a)
{
    while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
    SciaRegs.SCITXBUF=a;

}

void scia_msg(char * msg)
{
    int i;
    i = 0;
    while(msg[i] != '\0')
    {
        scia_xmit(msg[i]);
        i++;
    }
}

// Initialize the SCI FIFO
void scia_fifo_init()
{
    SciaRegs.SCIFFTX.all=0xE040;
    SciaRegs.SCIFFRX.all=0x2044;
    SciaRegs.SCIFFCT.all=0x0;

}

//===========================================================================
// No more.
//===========================================================================

my hyperterminal application is configured on COM1 9600 8-N-1 .

I was tried to changed baud rated by changing SciaRegs.SCIHBAUD and SciaRegs.SCILBAUD registers but no success .

please help me solve this problem . thanks .

  • this is my received data on hyperterminal .

  • Hi,

    Try using this ht file with Hyperterminal program (Keep the baud settings to default values)

    3187.SCI_96.zip

    Regards,

    Gautam

     

    If a post answers your question, please click on "This resolved my issue" button

    Are You A Beginner or New to TI's C2000™ Family? Do Check This Book!

  • In reply to Gautam Iyer:

    Dear Gautam ,

    thanks for your reply , but this file is not working , it says : Could not read session file : path/SCI_96.ht .


    Best Regards,

    Amir.

  • In reply to niruazmoon company:

    Amir, check this one: 6840.SCI_96.zip

    This seems to work.

    Regards,

    Gautam

     

    If a post answers your question, please click on "This resolved my issue" button

    Are You A Beginner or New to TI's C2000™ Family? Do Check This Book!

  • In reply to Gautam Iyer:

    Gautam,

    This file is working now , but I still receiving unrecognized words .

    Do I need to change LSPCLK ? if yes , how to change it ?

    Regards,

    Amir .

  • In reply to niruazmoon company:

    niruazmoon company
    Do I need to change LSPCLK ? if yes , how to change it ?

    Instead transmit continuous stream of data from the kit and observe the same on DSO. Verify whether the baud rate is as expected.

    Regards,

    Gautam

     

    If a post answers your question, please click on "This resolved my issue" button

    Are You A Beginner or New to TI's C2000™ Family? Do Check This Book!

  • In reply to Gautam Iyer:

    Gautam ,

    I measured baud rate on an analog oscilloscope  , it's ~ 9803.921569 .

    a pulse width of 102 μs was measured . ( 1 / 0.000102 = 9803.921569 )

    Regards,

    Amir .

  • In reply to niruazmoon company:

    Dear Gautam ,

    Do you have any advice ?

    Regards,

    Amir .

  • In reply to niruazmoon company:

    Sorry Amir, missed your post.

    niruazmoon company
    I measured baud rate on an analog oscilloscope  , it's ~ 9803.921569 .

    This is very strange, it has to be 9600+-0.5%

    9800 is not acceptable and hence you're receiving all garbage values. Correct the baud rate by configuring the respective H&L registers.

    Regards,

    Gautam

     

    If a post answers your question, please click on "This resolved my issue" button

    Are You A Beginner or New to TI's C2000™ Family? Do Check This Book!

  • In reply to Gautam Iyer:

    Gautam,

    I fixed the baud rate problem by setting SciaRegs.SCIHBAUD = 0x0002 and SciaRegs.SCILBAUD = 0x0090
     and I checked on oscilloscope too the baud rate is 9615.384615 . but I still can not receive correct data .

    I have to try SCIB instead SCIA , can you tell me the rx and tx pins on docking station or GPIO numbers of SCIB ?

    or any other advice ?

    Regards,

    Amir .

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.