LPUART 7 bit Mode Modification

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

LPUART 7 bit Mode Modification

跳至解决方案
1,849 次查看
engineer_attila
Contributor III

Hi folks,

I want to configure LPUART interface the 7 data bits, Even Parity, 1 Stop Bit, No Flow Control, 9600 baud rate.

(S32k144EVB-Q100 Yellow Card,LPUART0 instance , PTB0-Rx PTB1-Tx )

I couldn't select 7 bit mode on S32 Design Studio  or MBDT Toolbox.

When i examine the dataseet, There is possibly that use 7 bit mode after some modification

LPUART BAUD register M10 bit cleared

LPUART CNTRL register M7 bit setted

I modified the LPUART_SetBitCountPerChar() function on lpuart_hw_acccess.c file

ı just include  this 2 lines and delete other lines witihn this function for this experiment  
 

 

base->CTRL = (base->CTRL & ~LPUART_CTRL_M_MASK) | (0 << LPUART_CTRL_M_SHIFT) | (base->CTRL & ~LPUART_CTRL_M7_MASK) | (1 << LPUART_CTRL_M7_SHIFT);

base->BAUD &= ~LPUART_BAUD_M10_MASK;

 

 
But i coulnd't get any expected data from LPUART Tx line

 

What i need to do?

 

Best regards
0 项奖励
回复
1 解答
1,671 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@engineer_attila

I made some summaries,hope it works for you.

1.7-N-1      9600 No Flow Control          ->Set M = 0,M7 = 1,M10 = 0;

2.7-E/O-1  9600 No Flow Control          ->Set M = 0,M7 = 0,M10 = 0;

3.8-N-1      9600 No Flow Control          ->Set M = 0,M7 = 0,M10 = 0;

4.8-E/O-1  9600 No Flow Control          ->Set M = 1,M7 = 0,M10 = 0;

5.9-N-1      9600 No Flow Control          ->Set M = 1,M7 = 0,M10 = 0; 

6.9-E/O-1  9600 No Flow Control          ->Set M = 0,M7 = 0,M10 = 1;

7.10-N-1    9600 No Flow Control          ->Set M = 0,M7 = 0,M10 = 1;

 

在原帖中查看解决方案

7 回复数
1,773 次查看
engineer_attila
Contributor III

Hİ @Senlent Thank you for reply. 

I forgot to ask you. What is the proper configuration of lpuart_user_config_t for my situation?(7-E-1 9600 No Flow Control) ?

Sholud I add the  LPUART_7_BITS_PER_CHAR  line to  within lpuart_bit_count_per_char_t enum type(lpuart_driver.h)?

 

0 项奖励
回复
1,757 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@engineer_attila

no,this should not work, you can modify it by setting CTRL register.

0 项奖励
回复
1,746 次查看
engineer_attila
Contributor III

Hi @Senlent 

I changed the driver as you descirebed, send the string "abc" from s32k144 with 100msec delay. I got unreliable data from s32k144.

(It was changing over the time)

s32k144.png

(Perceived data from serial convertor(9600-7-E-1 No Flow Control))

receiver.png

When i send the same string from serial convertor , i saw what i send

Serial_Convertor.png

I search more robust solution for my problem

0 项奖励
回复
1,737 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@engineer_attila

Will there be such a problem when sending a single character?

My test here is normal, but I didn’t use an oscilloscope to capture whether the configuration is correct.

You can test whether the single-character sending and receiving is normal.

It takes a while to test

0 项奖励
回复
1,695 次查看
engineer_attila
Contributor III

Hi @Senlent , 

My configuration

lpuart_user_config_t lpuart0_InitConfig0 = {
  .transferType = LPUART_USING_INTERRUPTS,
  .baudRate = 9600U,
  .parityMode = LPUART_PARITY_EVEN,
  .stopBitCount = LPUART_ONE_STOP_BIT,
  .bitCountPerChar = LPUART_8_BITS_PER_CHAR,
  .rxDMAChannel = 0U,
  .txDMAChannel = 0U,
};

and also change the LPUART_SetBitCountPerChar() function as you descirebed 

I send a single character ('a')to the serial converter. I received from serial converter 

0x61(a)  0x7F(DEL) 

 

 

 

1,672 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@engineer_attila

I made some summaries,hope it works for you.

1.7-N-1      9600 No Flow Control          ->Set M = 0,M7 = 1,M10 = 0;

2.7-E/O-1  9600 No Flow Control          ->Set M = 0,M7 = 0,M10 = 0;

3.8-N-1      9600 No Flow Control          ->Set M = 0,M7 = 0,M10 = 0;

4.8-E/O-1  9600 No Flow Control          ->Set M = 1,M7 = 0,M10 = 0;

5.9-N-1      9600 No Flow Control          ->Set M = 1,M7 = 0,M10 = 0; 

6.9-E/O-1  9600 No Flow Control          ->Set M = 0,M7 = 0,M10 = 1;

7.10-N-1    9600 No Flow Control          ->Set M = 0,M7 = 0,M10 = 1;

 

1,787 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@engineer_attila

S32K-RM Chapter:

53.4.5.1 Data Modes
The LPUART transmitter and receiver can be configured to operate in 7-bit data mode by
setting CTRL[M7], 9-bit data mode by setting the CTRL[M] or 10-bit data mode by
setting BAUD[M10].

Senlent_0-1684136694372.png

test.

Senlent_1-1684137777992.png

 

send char "1" to PC ,"1" ascill ->0x31->0b00110001

PC will received hex 0xb1->0b10110001,bit 7 was set to 1.

this should be correct.