chipKIT® Development Platform

Inspired by Arduino™

How to send break char. Serial.print to start LIN frame

Created Tue, 03 Feb 2015 05:41:02 +0000 by Mincky


Mincky

Tue, 03 Feb 2015 05:41:02 +0000

My UART message has to start with a break character (= 11 x bit time low) to create a LIN protocol frame. How do I do this with Serial.begin / Serial.print. ..... I am using a Chipkit MAX32 with the Arduino kind IDE. I am new to this type of programming. Up to now I used MPLABx C compiler and fiddled the UART registers manually. The PIC32 has a hardware feature to generate a break by setting a bit in a control register and send a dummy char to send register.


majenko

Tue, 03 Feb 2015 10:26:30 +0000

There is no direct support in the chipKIT API for sending break characters. However, you can still directly manipulate the registers as you would in MPLAB-X.

Check the Board_Defs.h file for the variant of board you're using to find which UART port is mapped to which set of pins.


GrahamM242

Tue, 03 Feb 2015 11:08:24 +0000

As Matt suggests, you should still be able to directly manipulate the registers to set UTXBRK. While I haven't looked in depth, it seems you should then be able to use Serial.write() to send out your byte array, including an initial dummy byte (that the break replaces) and the rest of the LIN master message attached.

Don't attempt to utilise Serial.print for binary data - null bytes act as a terminator! In theory, you should be able to utilise Serial.flush to wait for the transmission to finish to get your response space.