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.

Problem in scib (UART) of TMS320F2812

Other Parts Discussed in Thread: TMS320F2812

Hello,


I'm using TMS320f2812 controller and quite a beginner in it.

I copied this sample code to understand the functioning of SCI interface . The code works fine when i use scia , but it shows no result when i use scib.

Code-

#include "DSP281x_Device.h"

void Gpio_select(void);
void InitSystem(void);  
void SCI_Init(void);
unsigned int baud_rate=0;
void main(void)
{
    char message[]={"The F2812-UART is fine !\n\r"};
    int index =0;            // pointer into string    
    long i;

    
    InitSystem();        // Initialize the DSP's core Registers
    
    Gpio_select();        // Setup the GPIO Multiplex Registers

    SCI_Init();
    while(1)
    {    
         ScibRegs.SCITXBUF=message[index++];
        while ( ScibRegs.SCICTL2.bit.TXEMPTY == 0); //wait for TX -empty
       
       if (index > 26)
       {
               index =0;
            for(i=0;i<150000;i++);     // Software - delay approx. 2 sec.
           }
    }
}     


void Gpio_select(void)
{
    EALLOW;
    GpioMuxRegs.GPAMUX.all = 0x0;    // all GPIO port Pin's to I/O
    GpioMuxRegs.GPBMUX.all = 0x0;   
    GpioMuxRegs.GPDMUX.all = 0x0;
    GpioMuxRegs.GPFMUX.all = 0x0;        
    GpioMuxRegs.GPFMUX.bit.SCIRXDA_GPIOF5 = 1; //SCI-RX
    GpioMuxRegs.GPFMUX.bit.SCITXDA_GPIOF4 = 1; //SCI-TX
    GpioMuxRegs.GPEMUX.all = 0x0;
    GpioMuxRegs.GPGMUX.all = 0x0;            
                                        
    GpioMuxRegs.GPADIR.all = 0x0;    // GPIO PORT  as input
    GpioMuxRegs.GPBDIR.all = 0x0;    // GPIO Port B15-B8 input , B7-B0 output
    GpioMuxRegs.GPDDIR.all = 0x0;    // GPIO PORT  as input
    GpioMuxRegs.GPEDIR.all = 0x0;    // GPIO PORT  as input
    GpioMuxRegs.GPFDIR.all = 0x0;    // GPIO PORT  as input
    GpioMuxRegs.GPGDIR.all = 0x0;    // GPIO PORT  as input

    GpioMuxRegs.GPAQUAL.all = 0x0;    // Set GPIO input qualifier values to zero
    GpioMuxRegs.GPBQUAL.all = 0x0;
    GpioMuxRegs.GPDQUAL.all = 0x0;
    GpioMuxRegs.GPEQUAL.all = 0x0;
    EDIS;
}     


void InitSystem(void)
{
       EALLOW;
       SysCtrlRegs.WDCR= 0x0068;        // Setup the watchdog
                                       // 0x00E8  to disable the Watchdog , Prescaler = 1
                                       // 0x00AF  to NOT disable the Watchdog, Prescaler = 64
       SysCtrlRegs.SCSR = 0;             // Watchdog generates a RESET    
       SysCtrlRegs.PLLCR.bit.DIV = 10;    // Setup the Clock PLL to multiply by 5
    
       SysCtrlRegs.HISPCP.all = 0x1; // Setup Highspeed Clock Prescaler to divide by 2
       SysCtrlRegs.LOSPCP.all = 0x2; // Setup Lowspeed CLock Prescaler to divide by 4
          
       // Peripheral clock enables set for the selected peripherals.   
       SysCtrlRegs.PCLKCR.bit.EVAENCLK=0;
       SysCtrlRegs.PCLKCR.bit.EVBENCLK=0;
       SysCtrlRegs.PCLKCR.bit.SCIAENCLK=0;
       SysCtrlRegs.PCLKCR.bit.SCIBENCLK=1;
       SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=0;
       SysCtrlRegs.PCLKCR.bit.SPIENCLK=0;
       SysCtrlRegs.PCLKCR.bit.ECANENCLK=0;
       SysCtrlRegs.PCLKCR.bit.ADCENCLK=0;
       EDIS;
}

void SCI_Init(void)
{
    ScibRegs.SCICCR.all =0x0007;       // 1 stop bit,  No loopback
                                       // No parity,8 char bits,
                                       // async mode, idle-line protocol
    ScibRegs.SCICTL1.all =0x0003;      // enable TX, RX, internal SCICLK,
                                   // Disable RX ERR, SLEEP, TXWAKE
    ScibRegs.SCIHBAUD = 0x0001;  // 9600 Baud ; LSPCLK = 31.25MHz  //1E7h
    ScibRegs.SCILBAUD = 0x00E7;    
    ScibRegs.SCICTL1.all =0x0023;    // Relinquish SCI from Reset
}

Could you please point out the mistakes in the above code.

Thanks in advance.

  • Rachit Jain said:
    GpioMuxRegs.GPFMUX.bit.SCIRXDA_GPIOF5 = 1; //SCI-RX
        GpioMuxRegs.GPFMUX.bit.SCITXDA_GPIOF4 = 1; //SCI-TX

    Hello,

    I saw that you have set GPIO for TX-A and RX-A, but where is the setting for RX-B and TX-B?

    You should modify the GPIOs setting for RX-B and TX-B (I don't know which pins they are, please check the datasheet).

    Best regards,

    Maria