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.

TMS320F28379D: change sci baud rate in run time

Part Number: TMS320F28379D

hello all,

I am trying to Chang sci baud rate in run time.  I used the following function to initialize sci buffer and set scib baud rate.

I tried use the same function to reset baud rate to other number in run time. It seems it can succeed several time then the uart will never receive anything from PC. 

Any suggestion or help will be appreciated. Thanks

scib_ini(uint16_t sciLbaud ){

ScibRegs.SCIFFTX.all = 0xE040;
ScibRegs.SCIFFRX.all = 0x2044;
ScibRegs.SCIFFCT.all = 0x0;

////--------------------
ScibRegs.SCICCR.all =0x0007;
// enable TX, RX, internal SCICLK, Disable RX ERR, SLEEP, TXWAKE
//
ScibRegs.SCICTL1.all =0x0003;
ScibRegs.SCICTL2.bit.TXINTENA =1;
// ScibRegs.SCICTL2.bit.RXBKINTENA =1;
// 115200 baud @LSPCLK = 22.5MHz (90 MHz SYSCLK)
// @LSPCLK = 50 MHz (200 MHz SYSCLK) HBAUD = 0x02 and LBAUD = 0x8B.
//
ScibRegs.SCIHBAUD.all =0x0000;
ScibRegs.SCILBAUD.all = sciLbaud; // // 53 for 115200
ScibRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset

}

  • Hi Hai Xuan,

    Do any of the error flags get set? There is a global RX error flag "SCIRXST.RXERROR" which is an OR of the various types of RX errors (flags are in the same register): BRKDT, FE, OE, and PE.
  • Thanks Devin, 

    I am newbie for the F28x.

    I will try to check in the flag in CCS.  How I can reset these flags?

  • Hi,

    I recommend using the SCI initialization functions we provide. The SCI is very particular about the order that bits should be set in order to configure the SCI properly.

    Regards,
    sasl
  • Hi sal,
    I can initialized sci successfully first time but failed when I try re-initialize the sci to another baudrate. what should I do else for this task?
  • another observation: when set baud rate smaller than previous one, it always succeed, but failed when try set the baud rate higher.
  • What baud rates are you trying to set?

    If resetting the SCI and re-initializing it is not working, then you can try to fix the issue by 1) disabling the peripheral clock 2) re-enabling the peripheral clock 3) initializing the SCI for your desired baud rate.

    Hope this helps.

    sal
  • Sal, appreciate your replay.
    '...resetting the SCI and re-initializing it ...' could you explain a little bit. what function I can use to reset the SCI
    I tried set 115200 and 1.25M.

    Currently, I use the code as following :

    switch (temp1){
    case 1:
    // ScidRegs.SCICTL1.bit.SWRESET = 0;
    // scid_fifo_init();
    scid_init_with_baud_set(53); //115200
    ScidRegs.SCICTL1.bit.SWRESET = 0;
    ScidRegs.SCICTL1.bit.SWRESET = 1;

    break;
    case 12:
    // ScidRegs.SCICTL1.bit.SWRESET = 0;
    // scid_fifo_init();
    scid_init_with_baud_set(4); //1.25Msps
    ScidRegs.SCICTL1.bit.SWRESET = 0;
    ScidRegs.SCICTL1.bit.SWRESET = 1;

    break;


    scid_init_with_baud_set(uint16_t sciLbaud ){
    ScibRegs.SCIFFTX.all = 0xE040;
    ScibRegs.SCIFFRX.all = 0x2044;
    ScibRegs.SCIFFCT.all = 0x0;

    ////--------------------
    ScibRegs.SCICCR.all =0x0007;
    // enable TX, RX, internal SCICLK, Disable RX ERR, SLEEP, TXWAKE
    //
    ScibRegs.SCICTL1.all =0x0003;
    ScibRegs.SCICTL2.bit.TXINTENA =1;
    // ScibRegs.SCICTL2.bit.RXBKINTENA =1;
    // 115200 baud @LSPCLK = 22.5MHz (90 MHz SYSCLK)
    // @LSPCLK = 50 MHz (200 MHz SYSCLK) HBAUD = 0x02 and LBAUD = 0x8B.
    //
    ScibRegs.SCIHBAUD.all =0x0000;
    ScibRegs.SCILBAUD.all = sciLbaud; // // 53 for 115200
    ScibRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset

    }
  • If the fifo also need to be reset or initialized agian?
  • Hi,

    I recommend following the same initialization sequence in the example code to do the re-initialization. You can look at the echoback example for this.

    1) sci_fifo_init()
    2) sci_echoback_init()

    This should reset the FIFOs and reset the SCI and then configure it again properly.

    Additionally, the SCI may not be able to support the 1.25M baud rate. That seems very high, and I have not tried to use a baud rate that high on C2000.

    Regards,
    sal
  • sal,

    I actually tried the sequence you gave, it appeared still the sci will failed to receive or send (I did not debug in detail).

    You mentioned reset the peripheral clock. what function I can used to reset the peripheral? Will the reset of peripheral clock affect other function, such as ADC, DAC , spi etc.., because I do not want to bother these things running.

     As for the 1.25M, it seems run Ok, at least it run well during my development. Of course, i will not use such high baud rate after the development. 

  • Look at DisablePeripheralClocks() in F2837xD_SysCtrl.c

    You can just disable the SCI peripheral clock for the SCI module you are using. This should not affect the ADC or DACs. It certainly will not turn the other peripherals. But you may observe some differences in power consumption when disabling and enabling peripheral clocks. But if it is just for an SCI module, then it should not be significant.

    sal
  • hi sal,

    I read the code and found there is a CpuSysRegs.PCLKCR7.bit.SCI_D = 1; to control the scid clock.

    Will the settings of CpuSysRegs.PCLKCR7.bit.SCI_D = 0 or 1 be sufficient to reset the clock of scid?

    My thought is as following, would you help check if it is reasonable ?

    ....
    ScidRegs.SCICTL1.bit.SWRESET = 0
    ScidRegs.SCICTL1.bit.SWRESET = 1
    CpuSysRegs.PCLKCR7.bit.SCI_D = 0

    scid_fifo_initial()
    scid_initilal() //with new baud rate

    CpuSysRegs.PCLKCR7.bit.SCI_D = 1
    .....
  • That won't work.

    Here is what I suggest.

    CpuSysRegs.PCLKCR7.bit.SCI_D = 0
    CpuSysRegs.PCLKCR7.bit.SCI_D = 1

    ScidRegs.SCICTL1.bit.SWRESET = 0

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

    Regards,
    sal