Hi Marek
I have used many Kinetis parts with modems, GPS module etc. and never had a problem with noise issues. At 9'600 Baud and cables of several meters I can't imagine any such problems.
My feeling is that the technique of using blocking calls is what is causing the basic difficulties. You may be able to solve it with some 'tuning' and trickery to ensure that the modules don't lose data in simple circumstance but it doesn't look to be a very good basis for continued development (complicated, unreliable and difficult to maintain).
In case you have continued complications I recommend that you use the Open-Source (free) uTasker project since it will give you low footprint for the KL03 and immediate reliability and ease of development (you can also connect your modem to your development PC's COM port and use its KL03 simulator to complete all firmware development, testing, debugging (in VisualStudio) without needing the KL03 HW and slow debugging techniques).
Here is an extract from its UART PPP code which shows connecting to a modem, handling communication timeout and collecting received characters. It works on all Kinets parts (LPUARTs , UARTs, with or without DMA) and is non-blocking so that there are no issues running the protocols in parallel with other application tasks. The solution has been used in many Kinetis based industrial products doing this type of thing, has a 6 year track record of reliability on Kinetis and so allows anyone to simplify development and reduce project times.
// PPP task
//
extern void fnPPP(TTASKTABLE *ptrTaskTable)
{
static int iPPPstate = 0;
static unsigned char ucInputMessage[PPP_RX_BUFFER_SPACE]; // reserve space for receiving messages
static QUEUE_HANDLE PPP_PortID = 0;
if (iPPPstate == 0) { // UART initialisation and modem dial-in
TTYTABLE tInterfaceParameters; // table for passing information to driver
tInterfaceParameters.Channel = PPP_UART; // set UART channel for serial use
tInterfaceParameters.ucSpeed = SERIAL_BAUD_9600; // baud rate
tInterfaceParameters.Rx_tx_sizes.RxQueueSize = PPP_RX_BUFFER_SIZE; // input buffer size
tInterfaceParameters.Rx_tx_sizes.TxQueueSize = PPP_TX_BUFFER_SIZE; // output buffer size
tInterfaceParameters.Task_to_wake = OWN_TASK; // wake self when messages have been received
tInterfaceParameters.Config = (CHAR_8 + NO_PARITY + ONE_STOP + CHAR_MODE);
if ((PPP_PortID = fnOpen(TYPE_TTY, FOR_I_O, &tInterfaceParameters)) != NO_ID_ALLOCATED) { // open serial port with defined parameters
fnDriver(PPP_PortID, (TX_ON | RX_ON), 0); // enable rx and tx
}
fnWrite(PPP_PortID, (unsigned char *)"AT$I=10\n\r", 9); // establish a connection to the modem
uTaskerMonoTimer(OWN_TASK, (DELAY_LIMIT)((0.2 * SEC)/1000), E_TIMER_PPP); // start a timer to monitor reception
iPPPstate = PPP_DIALING_IN;
}
while (fnRead(ptrTaskTable->TaskID, ucInputMessage, HEADER_LENGTH) != 0) { // check task input queue
switch (ucInputMessage[MSG_SOURCE_TASK]) { // switch depending on message source
case TIMER_EVENT: // software timer has fired
switch (ucInputMessage[MSG_TIMER_EVENT]) {
case E_TIMER_PPP: // modem hasn't responded within the monitor time period
fnDebugMsg("No response from modem");
break;
default:
break;
}
break;
}
}
// PPP character reception
//
while (fnRead(PPP_PortID, &ucInputMessage[ppp_frame_length], 1) != 0) { // while serial input waiting
// Handle modem reception
//
... project specific stuff here....
}
}
UART documentation: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF
UART numbering: http://www.utasker.com/kinetis/UART_LPUART.html
KL03: http://www.utasker.com/kinetis/FRDM-KL03Z.html
Open Source links: http://www.utasker.com/kinetis.html
Regards
Mark