S32K144 LPUART baud rate change

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S32K144 LPUART baud rate change

609件の閲覧回数
seungwoolee
Contributor II

Hello,

I have a trouble to change baud rate from 500kbps to 1Mbps.

I tried to change it by setting the Baudrate of the LPUART1 component configuration to 1Mbps(1000000) and generating the processor expert code.

Nothing happened and the baud rate is still 500kbps.

Please let me know how to solve this problem and what kinds of things I might set incorrect ways.

LPUART0_CLK uses SIRCDIV2_CLK (8MHz).

BUS_CLK 40MHz, FIRC_CLK 48MHz

(If I could upload the setting image of component inspector, it would be helpful to understand the situation, but I am not able to do that due to the company's policy)

Plus, I have to change the LPUART buadrate by product models. (e.g. A model: 500kbps, B model: 1Mbps)

Are there any ways to implement this easily in source code?

 

 

 

 

0 件の賞賛
返信
5 返答(返信)

584件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@seungwoolee

I made a demo for you,the hardware base on S32K144EVB

1.default baud rate is 500K,

2.push sw3 to change the baud to 1000K

Senlent_0-1702021980648.png

 

0 件の賞賛
返信

575件の閲覧回数
seungwoolee
Contributor II

Hi,  Senlent

 

Thank you so much for your support.

I found that the baudrate of the existing code was actually changable by monitoring a waveform with oscilloscope.

The problems is that the code example below works in 500kbps, but doesn't work in 1Mbps.

The function __read_register() is a code implemented to read registers of the certain LED driver IC after sending a read command through UART_TX to the IC and filling up read buffers.

I think that the sub-functions are not stable and they could cause errors in 1Mbps.   

Could you correct the sub-functions below?
Or, Could you send an example code is able to transmit, receive and handle multiple bytes?

 

Uart__Clear_RXbuffer(uint8_t len)

Uart__Clear_RXbuffer(uint8_t len)

Uart__send_TX(uint8_t buffer[], uint16_t *length) 

 

[Example code]

static bool __read_register(uint8_t frame_init, uint8_t lmmAddr, uint8_t regAddr, uint8_t readBuffer[], uint8_t lenByte)
{
    uint8_t txBuffer[RegBufferLength], read_length, pos, retry_cnt = 0;
    uint16_t txBufferLength = 0;
   
 
    read_length = 5 + lenByte + read_CRC_Len;
    pos = read_length - (lenByte + read_CRC_Len);
 
    do
    {
    if((++retry_cnt) > 3)
    {
    return false;
    }
 
    Uart__Clear_RXbuffer(read_length);                                                          //read_length is only used for clearing read buffers. (It's kind of transmit buffer to send rather than read buffer length)
    UserDefine__Delay_ms(1);
 
    __write_RegisterBuffer(frame_init, lmmAddr, regAddr, NULL, 0, txBuffer, &txBufferLength);   //Fill buffer to send including Frame_INIT, lmmAddr, regAddr, CRCH, CRCL)
    UserDefine__Delay_ms(1);
 
    Uart__send_TX(txBuffer, &txBufferLength);                                                   //send buffer data through actual UART. uint8_t buffer[], uint16_t *length
    UserDefine__Delay_ms(1);
 
    } while (!Uart__Read_RXbuffer(read_length, readBuffer));                                        //read until readBuffer to empty
                                                                                                    //not related to actual register, just fill the buffer until read data end.
 
 
for(uint8_t i = 0; i < lenByte; i++)
{
readBuffer[i] = readBuffer[pos + i];                                                        //Excluding not data information(CRCL,H), only allocating DATA to readBuffer[]....[]
//UserDefine__Delay_ms(1);
}
    //UserDefine__Delay_ms(1);
 
 
    return true;
}
 
 
void Uart__Clear_RXbuffer(uint8_t len)
{
status_t status;
 
Rx_bufferIdx = 0;
 
for(uint8_t i = 0; i < len; i++)
{
Rx_buffer[i] = 0;
}
 
LPUART_DRV_ReceiveData(INST_LPUART1, Rx_buffer, len);
 
}
 
 
void Uart__Clear_RXbuffer(uint8_t len)
{
status_t status;
 
Rx_bufferIdx = 0;
 
for(uint8_t i = 0; i < len; i++)
{
Rx_buffer[i] = 0;
}
 
LPUART_DRV_ReceiveData(INST_LPUART1, Rx_buffer, len);
 
}
 
void Uart__send_TX(uint8_t buffer[], uint16_t *length)
{
 
    LPUART_DRV_SendDataBlocking(INST_LPUART1, buffer, *length, UART_TIMEOUT);
 
 
*length = 0;
}
0 件の賞賛
返信

523件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@seungwoolee

You can test the demo I sent you before, which can send back the received string. And I tested its baud rate using an oscilloscope and everything is fine.

0 件の賞賛
返信

468件の閲覧回数
seungwoolee
Contributor II

Hello, Senlent

 

Thank you for your support.

Unfortunately, I have not yet solved the problem.

The LED driver IC is using the UART half-duplex mode and CAN physical layer. (not real CAN protocol,but just utilizing CAN signal level for EMC stability)

As a result, in terms of the slave device(LED driver IC), the TX signal is echoing on the RX line.

Similarily, the TX signal of master device(S32K144) is also echoing on the RX line.

That's why I modified the software to exclude forcibly the echoed TX data on RX pin after receiving RX data.

Do you have any idea not to read the echoed TX data on RX line?

Is there any possibilities that this kind of communcation type could cause receive errors in higher baudrate  (some kinds of bit lost or timing delay, and so on)

(There is no receive error in 500kbps, but the data can not be read in 1Mbps

0 件の賞賛
返信

461件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@seungwoolee

You should contact your LED IC supplier for technical support. They will definitely have similar control solutions.

We can provide you with all support for S32K peripherals, but if these communications are not standard communication methods, then I cannot give you useful advice.

0 件の賞賛
返信