Uart termios settings

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Uart termios settings

2,311 Views
tonymakkiel
Contributor III

Hi,

       I am running the uart dma_transfer example within KDS 2 on TWR-KL43Z. The example works fine when I use gtkterminal. I tried to emulate the same by sending a character 'A' 20 times. But, the twr does not seem to receive the data.

Can somebody please confirm whether the following termios settings is sufficient?

 

 

ret = cfsetispeed(&uart_termios, B115200);  /* Disable parity and set 1 stop bit */ uart_termios.c_cflag &= ~( PARENB | CSTOPB); uart_termios.c_cflag |= (CS8 | CREAD | CLOCAL);  /* Disable Input/Output flow ctrl,*/ uart_termios.c_iflag &= ~(IXON | IXOFF | INPCK | CRTSCTS); uart_termios.c_iflag |= ( IGNPAR | IXANY );

 

I have also attached the code I try to emulate uart on the host linux side.

 

gcc test.c -l pthread -o test

 

Many Thanks,

Tony

Original Attachment has been moved to: test.c.zip

Labels (1)
0 Kudos
6 Replies

1,982 Views
tonymakkiel
Contributor III

It works on Windows. So it should be one of the termios settings!

0 Kudos

1,982 Views
tonymakkiel
Contributor III

Fixed on Linux as well. There was some stray settings which got read from the system. Once the uart control bits were overwritten, it started working.

Thank you for your help Xiangjun Rong.

0 Kudos

1,982 Views
sujay1
Contributor V

Please explain how you got it working as I'm stuck with the same.

0 Kudos

1,982 Views
tonymakkiel
Contributor III

As it has been quite a while, I do not remember what was the fix. But you can verify whether it is termios mismatch by trying to open the port with some serial tools eg: gtkterm etc

0 Kudos

1,982 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Tony,

Regarding your application, I suppose that you use PC to communicate with TWR-KL43Z via RS232 instead of using USB port which is treated as virtual com, is it correct?

If you use RS232 port, as you know that the TWR-Kl43 does not has RS232 port, in the case, you have to establish a tower system with TWR-KL43Z, TWR-SER which has RS232 port and Primary/Secondary elevator board, you can connect the RS232 port of PC to RS232 port on TWR-SER board. Furthermore, you have to set the jumper correctly and power supply correctly, on the TWR-KL43Z, you have to close pin1&2 for J5, close pin1&2 for J3, while you have use UART2 module(PTE23 and PTE22) for KL43Z. For the TWR-SER board, you have to close pin1&2  for J17 and J19.

Regarding your code run in PC with Linux OS, it sounds good that you create a thread which monitors the RS232 port, while you press Ctrl+C, signal_hdlr() is run, which close all the thread and current progress. But I am not very familiar with Linux and struct termios, do you means that your code can run the virtual USB Com instead of RS232?

If it is not your scenario, I am  sorry, pls tell me the hardware connection.

BR

Xiangjun Rong

0 Kudos

1,982 Views
tonymakkiel
Contributor III

Hi Xiangjun Rong,

          I don't think set up is the problem (Note, both Tx  and Rx works if I use gtkterm). I am using TWR-SER board (PC connected to the RS232 port of the TWR-SER).

The problem is when I run the attached code, Tx does not happen (infact KL43Z does not even call the DMA interrupt.).

The SDK example code within the SDK echoes back what ever it received. My test code can receive data. But KL43 does not seem to receive data.

Many Thanks,

Tony

0 Kudos