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
Original Attachment has been moved to: test.c.zip
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.
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
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.
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.