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.

Differences SCIA & SCIB



Hello together, a have got a question. I have a system which is communicating over USB using SCI-A, works fine. Now I wanted to use SCI-B for the RS485 communication. Sofar I understood, there are no differences between SCI-A and SCI-B except the one runs on "SciaRegs" and the other on "ScibRegs". Therefore, I have just changed the registers from "SciaRegs" to "ScibRegs" everywhere in the code. I have also deactivated RX/TX GPIOs of SCIA and activated RX/TX GPIOs of SCIB, but somhow I still cant get any transmission over my RS485 interface. Are there any other differences to be considered?

my initialization, "SCI_REG_A" is defined and can be changed to "SciaRegs" or "ScibRegs",

 

void scia_fifo_init()
{
    SCI_REG_A.SCIFFTX.all=0xE040;    //SCI_FIFO transmit register
    SCI_REG_A.SCIFFRX.all=0x204f;    //SCI_FIFO receive register
    SCI_REG_A.SCIFFCT.all=0x0;        //SCI_FIFO control register

}


void scia_echoback_init()
{
     SCI_REG_A.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
                                                                      // No parity,8 char bits,
                                                                     // async mode, idle-line protocol
    SCI_REG_A.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,
                                                                     // Disable RX ERR, SLEEP, TXWAKE
    SCI_REG_A.SCICTL2.all =0x0003;
    SCI_REG_A.SCICTL2.bit.TXINTENA =1;//enable TX interrupt caused by TXRDY flag
    SCI_REG_A.SCICTL2.bit.RXBKINTENA =1;//enable RX interrupt caused by RXRDY flag or the BRKDT flag

     SCI_REG_A.SCIHBAUD    =0x0000;
    SCI_REG_A.SCILBAUD = 0x001B;        // 1Bh = 115.2Kbaud @ LSPCLK = 100/4 MHz
    SCI_REG_A.SCICTL1.all =0x0023;  // Relinquish SCI from Reset
}

 

 

//deactivate SCI-A GPIOs and activate SCI-B GPIOs

void comm_adjustment_init(void)
{
    EALLOW;
   
    //--------------------------------------------------------------------------------------
//  GPIO-09 - PIN FUNCTION = --Spare--
    GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 2;        // 0=GPIO,  1=EPWM5B,  2=SCITX-B,  3=ECAP3
//    GpioCtrlRegs.GPADIR.bit.GPIO9 = 0;        // 1=OUTput,  0=INput
//    GpioDataRegs.GPACLEAR.bit.GPIO9 = 1;    // uncomment if --> Set Low initially
//    GpioDataRegs.GPASET.bit.GPIO9 = 1;        // uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-11 - PIN FUNCTION = --Spare--
    GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 2;    // 0=GPIO,  1=EPWM6B,  2=SCIRX-B,  3=ECAP4
//    GpioCtrlRegs.GPADIR.bit.GPIO11 = 0;        // 1=OUTput,  0=INput
//    GpioDataRegs.GPACLEAR.bit.GPIO11 = 1;    // uncomment if --> Set Low initially
//    GpioDataRegs.GPASET.bit.GPIO11 = 1;        // uncomment if --> Set High initially
   
    //--------------------------------------------------------------------------------------
//  GPIO-21 - PIN FUNCTION = --Spare--
    GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 0;    // 0=GPIO,  1=EQEPB-1,  2=SPISOMI-C,  3=CANRX-B
    GpioCtrlRegs.GPADIR.bit.GPIO21 = 1;        // 1=OUTput,  0=INput
//    GpioDataRegs.GPACLEAR.bit.GPIO21 = 1;    // uncomment if --> Set Low initially
    GpioDataRegs.GPASET.bit.GPIO21 = 1;        // uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
   
    //--------------------------------------------------------------------------------------
//  GPIO-28 - PIN FUNCTION = SCI-RX
    GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 0;    // 0=GPIO,  1=SCIRX-A,  2=Resv,  3=TZ5
    GpioCtrlRegs.GPADIR.bit.GPIO28 = 0;        // 1=OUTput,  0=INput
//    GpioDataRegs.GPACLEAR.bit.GPIO28 = 1;    // uncomment if --> Set Low initially
//    GpioDataRegs.GPASET.bit.GPIO28 = 1;        // uncomment if --> Set High initially
//--------------------------------------------------------------------------------------
//  GPIO-29 - PIN FUNCTION = SCI-TX
    GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 0;    // 0=GPIO,  1=SCITXD-A,  2=Resv,  3=TZ6
    GpioCtrlRegs.GPADIR.bit.GPIO29 = 0;        // 1=OUTput,  0=INput
//    GpioDataRegs.GPACLEAR.bit.GPIO29 = 1;    // uncomment if --> Set Low initially
//    GpioDataRegs.GPASET.bit.GPIO29 = 1;        // uncomment if --> Set High initially
//--------------------------------------------------------------------------------------

    EDIS;    // Disable register access   
}

 

thx,

 

bye

  • none,

    From a quick glance, everything looks ok.

    I would recommend looking at the interrupt flag clearing in your SCI's ISR code.

    If that doesn't solve it putting a probe on the SCIB pins or putting breakpoints in to see where the code is getting stuck could be useful.  This will help you determine if its an issue with the init code or the ISR/periodically running code.


    Thank you,
    Brett

  • Hi Brett, thx for your response.

    I am sending data every second just to test my system. I am calling my "scia_xmit(54)" function, this works, have used breakpoints to verify . After writing my data to the SCITXBUF, I am reading my SCIFFTX register immediately, where I am getting always the number  40960. I am not sure whats the problem. I have used the loopback example to test my RS485, works without problems, there I am reading always 61352 in my SCIFFTX register after data transmission where TXFFIENA and  TXFFINT Flag are set to 1.

    void scia_xmit(int a)
    {
      
        while (SCI_REG_A.SCIFFTX.bit.TXFFST != 0) {}

        SCI_REG_A.SCITXBUF=a;
        interrupt_test=ScibRegs.SCIFFTX.all;

    }

  • Hi Brett, short update. I have found the problem. I didnt initialized clock for my SCI-B interface.

     

    thx for your time.

     

    Adieu

     

     

  • Very good observation thanks for the reply.