Hello all,
I am working with the FRDM-KL25Z and CodeWarrior 10.5. I am trying to send and receive several bytes by the UART, but I am not able to do so.
I am already able to receive one byte, but there is no way to receive more than one byte. Please let me show you what I am doing:
- I am using a terminal called Docklight to send 10 bytes through RS232. I designed a pcb with a 232 tranceciver, so the FRDM-KL25Z UART pins receive the proper voltage leveIs.
- I check by an oscilloscope that these 10 bytes arrive to the FRDM-KL25Z UART pins.
- Both the terminal and the FRDM-KL25Z are configured with 9600 bauds, 8 data bits, 1 stop bit and no parity.
- I use the AsynchroSerial component. Please find attached its settings.
I try to receive the datas by polling, so first I use the method GetCharsInRxBuf() in order to know the number of bytes I receive. And then, I try to charge all these bytes with the method RecvChar into an array. Please find attached the code in a screen capture.
The point is that GetCharsInRxBuf always tells that I receive only 1 byte.
Any clue what I am doing wrong? Thank you in advance.
Solved! Go to Solution.
Hello Aitor,
In the file UART.h under the Generated_Code folder you will find a macro called UART_INP_BUF_SIZE which is used in the file UART.c. This macro is the bytes that the peripheral is expecting so you can convert that macro into a variable and change that variable in every OnFullRxBuf function.
Please let me know if this information is useful or if I can do anything else for you.
Best regards,
Earl.
Hello Aitor,
Why don't you use the function ASerialLdd1_ReceiveBlock? I think that it fits better with your application. In fact, the function UART_RecvChar uses the function ASerialLdd1_ReceiveBlock.
Also, the component Serial_LDD can be useful for you. I recommend you to take a look into it. It also includes a function to send or receive a block of data. This component is has a lower level of abstraction so is more efficient.
Best regards,
Earl.
Thank you Earl,
I will have a look to your recommendations and see if I get something.
However, I still don’t understand what I was doing wrong.
BR.
Aitor Aranzabal
De: EarlOrlando
Enviado el: jueves, 23 de julio de 2015 22:22
Para: AITOR ARANZABAL
Asunto: Re: - Can´t receive more than one byte by UART.
<http://jiveon.jivesoftware.com/mpss/c/zwA/PDcDAA/t.1oy/vsj1S9XrS2SqJTesJSaEtw/h0/eqhG5v9o4WV1pCmWaB03cUjBPgRj-2F3GoJUaXSZ409bQ-3D> Freescale Community
Can´t receive more than one byte by UART.
reply from Earl <http://jiveon.jivesoftware.com/mpss/c/zwA/PDcDAA/t.1oy/vsj1S9XrS2SqJTesJSaEtw/h1/eqhG5v9o4WV1pCmWaB03cUjBPgRj-2F3GoJUaXSZ409bSFptD52UNhkZRd210-2FIwQWXO21D1d1BJXlhaAsM4UJCEzuXqJS9olAmWqS5vTZ-2BAY-3D> Orlando Ramirez Sanchez in Kinetis Microcontrollers - View <http://jiveon.jivesoftware.com/mpss/c/zwA/PDcDAA/t.1oy/vsj1S9XrS2SqJTesJSaEtw/h2/eqhG5v9o4WV1pCmWaB03cUjBPgRj-2F3GoJUaXSZ409bSWu-2FQYmmII2lvY0tnf-2BikHrJzZIRuMazuccgcUMGO7F-2BO2jA26dDrVQB9krc5ou8g-3D> the full discussion
Hello again,
After playing arround with different possiblities, I was able to receive the 10 bytes. I discarded the polling and I worked with the event OnFullRxBuf(void).
I had to change the "Input buffer size" to 10 in the processor expert component features. Please have a look below. Please remind that I am using AsynchroSerial component.
In my application, I will know the number of bytes that I will receive each time, but not always will be 10 bytes. So I would need to change the input buffer size each time. Is it a way to do it by firmware? I mean inserting code. I am having a look in the datasheet of the "KL25 Sub-Family Reference Manual" in order to find the proper register, but no way
Thank you in advance.
Hello Aitor,
In the file UART.h under the Generated_Code folder you will find a macro called UART_INP_BUF_SIZE which is used in the file UART.c. This macro is the bytes that the peripheral is expecting so you can convert that macro into a variable and change that variable in every OnFullRxBuf function.
Please let me know if this information is useful or if I can do anything else for you.
Best regards,
Earl.
Hello Earl,
I did it and it works. Great.
I had to protect the component from the overwritting in the processor expert generating code.
Thanks a lot.