Zigbee Beestack UART Issue with UART Baudrate at runtime

cancel
Showing results for 
Search instead for 
Did you mean: 

Zigbee Beestack UART Issue with UART Baudrate at runtime

Jump to solution
692 Views
josedanielpena
Contributor II

Zigbee Beestack Wireless UART Issue with UART Baudrate

Good Morning to Everybody:

I am writing an application that needs to change the uart baudrate at runtime several times. After some infructuous work with a generic zigbee application i decided to go back to the Wireless UART Example.

The wireless UART has an option to change the baudrate at runtime when the application is running. It supposed to make a cycle between 1200, 2400, 4800, 9600, 19200, 38400. The application starts with 38400 when it passes to Application mode.

pastedImage_0.png

Later when the user press SW4 for the first time, the application cycle runs to the next baudrate (1200).

pastedImage_2.png

pastedImage_1.png

When the application cycle for the second time, the UART baudrate stares at 844bps when it supposed to be at 2400.

pastedImage_4.png

Here we measure the baud rate with the logic analyser and we get

pastedImage_3.png

At a third time with the SW4, the UART cycle runs at a 759 baudrate where it supposed to be at 4800.

pastedImage_5.png

pastedImage_6.png

After the UART gets this baudrate (759bps) the application won't change its baudrate any more.

The UartGetStatus function returns 0x00 (everything ok) after each change.

Something to note is that the UartGetConfig function doesn't return the real UART baudrate, but the other parameters.

pastedImage_7.png

This issue is present either working with IAR Embedded Workbench form ARM (we use version 7.10) and the Kinetis Design Studio 2.0 or 3.2.

We are using Beestack 4.0.1 (Beekit 3.0.2).

The tests were made with two TWR-KW21 (Zigbee Coordinator and Zigbee Router) as with our own test boards, showing the same results.

Is there an error with the beestack or is the silicon that has this issue? If it is the beestack, how can we solve this to succesufully change the baudrate of the UART at runtime as many times the application needs?

Thanks in advance.

Labels (2)
1 Solution
254 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

 

The error seems to be related to some configuration lines of the baud rate registers.   

In the UartSetConfig function located in UART.c, please comment the following lines of code:

       mUartModule[UartNumber].UartRegs->BDH = 0x00;

       mUartModule[UartNumber].UartRegs->BDH |= (uint8_t)((mUartSBR >> 8) & gUART_BDH_MASK_c);

 

Then, add the following line of code instead:

        mUartModule[UartNumber].UartRegs->BDH = (uint8_t)(((mUartSBR >> 8) & gUART_BDH_MASK_c)|((mUartModule[UartNumber].UartRegs->BDH)&(~gUART_BDH_MASK_c)));

The reason why the first two lines do no work it’s because the only way for the UARTx_BDH register to change is until the UARTx_BDL is written; when the code has two consecutive changes in the BHD register it will only be taken into account the last one if it’s followed by the write of the BDL register.

The new line has a mask to clear the register of the last configured data and writes the register with the new data. 

View solution in original post

2 Replies
255 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

 

The error seems to be related to some configuration lines of the baud rate registers.   

In the UartSetConfig function located in UART.c, please comment the following lines of code:

       mUartModule[UartNumber].UartRegs->BDH = 0x00;

       mUartModule[UartNumber].UartRegs->BDH |= (uint8_t)((mUartSBR >> 8) & gUART_BDH_MASK_c);

 

Then, add the following line of code instead:

        mUartModule[UartNumber].UartRegs->BDH = (uint8_t)(((mUartSBR >> 8) & gUART_BDH_MASK_c)|((mUartModule[UartNumber].UartRegs->BDH)&(~gUART_BDH_MASK_c)));

The reason why the first two lines do no work it’s because the only way for the UARTx_BDH register to change is until the UARTx_BDL is written; when the code has two consecutive changes in the BHD register it will only be taken into account the last one if it’s followed by the write of the BDL register.

The new line has a mask to clear the register of the last configured data and writes the register with the new data. 

View solution in original post

254 Views
josedanielpena
Contributor II

Thanks a lot!