1 of 1 people found this helpful
1)how to send something that is not an ASCII char?
UART is mainly made for transmitting ASCII and you can get one char after the other. Receiving binary data (0 to 0xff or 0 to 255) can work using UART_ReadRxData() but you need to check whether a byte was already received.
2)what happen if I send a number higher than 255? is it valid if i set 4byte buffer?
Only the lower 8 bits will be sent regardless of the buffer size.
3) Could explain when to create a Circular Buffer?
The component handles a circular buffer for you already. Just set the buffer size to > 4 (I use at least 80) and check for UART_GetRxBufferSize() > 0 to see if a byte is ready to read.
1 of 1 people found this helpful
Here are some code samples to show how I did it, sorry I cant post my complete project but this might help you :
Param is my string buffer that contains the command parameters. You need to #include <stdio.h> and #include <string.h>
if (0==sscanf(param,"%hu",&NrOfSamples)) return errWrongCmdParameters;
Or look at these examples for usage :
Thank you for the help guys.
Sorry for the mega post, I imagine they could be silly questions but I dont know where to find these informations, I know theory about RS232 protocol but to make it, it's really different .
I hope not to bother you, if you could suggest me some material to improve my knowledge it could be great.
To Odissey1 and user_347933176: actually I am not be able to manage that kind of code I'm studying right now pointers in C, so this kind of code is quite hard for me, maybe in 1 or 2 weeks it could be an interesting exercise.
1)I followed Bob's advice about checking the if a byte was already received using if(UART_RX_STS_FIFO_NOTEMPTY==1) and it works fine but after this i used to send back data with UART_WriteTxData() checking on FIFO if empty and pn rxData, but without good results...It doesnt works because it seems the second if condition is never true.
This was the easy code I used:
rxData = UART_ReadRxData();
if( UART_TX_STS_FIFO_EMPTY!=0 && rxData!=0 )
2)Luckly I found on the code examples something really easier that 'UART-full duplex example'.
so I understood that is not enough to check only one bit in the RxDataRegister but I have to check also bit about error (Parity,stop,break..) but I cant understand the reason, If I want to send only the char C..why I have to check all these stuff,
Why happen some errors if I want send just one byte.
3) Using the code example i cant understand this:
rxStatus = UART_ReadRxStatus();
if((rxStatus & (UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR |
UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN)) != 0u)
This is a bitwise operation isn't it?
If yes , the output of UART_ReadRxStatus() is an uint8 and the other are all single bit how is possible to make any operation between a single bit and a byte?
FORTH for ....
if you want to show an example of UART,
see: https://sourceforge.net/projects/mecrisp/files/Cypress/ >>> mecrisp-stellaris-2.4.5 for cy8c.........zip
Locking for 'cy-terminal.s', you will find some assemblercode.
Mecrisp-Stellaris-FORTH is available for following Eva-Kits / PSoC`s :
Board: / PSoC:
CY8CKIT-043 -> cy8c4247azi
CY8CKIT-044 -> cy8c4247azi
CY8CKIT-046 -> cy8c4248bzi
CY8CKIT-049 -> cy8c4245axi
CY8CKIT-050 -> cy8c5868axi
CY8CKIT-059 -> cy8c5888lti
FreeSoC2 -> cy8c5888axi
The porting for the PSoC 6 is also planned. With this FORTH-pagage it is possible to test all C-applications interactively without debugger. The Kernel have integrated an interpreter and compiler. The Compiler is extendabel in FORTH itself (generic and generative programming).
If you would like to know more about FORTH, you will find the classic Starting-FORTH and Thinking-FORTH by Leo Brodie:
The Definition of ANS FORTH you can find here: http://lars.nocrew.org/dpans/dpans.htm
If you want to know more about Mecrisp-Stellaris you are right here: