- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
am using psoc3 and i need to recieve 30 bytes in Rxbuffer of UART[v2.10].
i have made my buffer size 30 as well as the Rxinterrupt is also generated.
but only first 4 bytes are recieving properly , ferther bytes are getting overwrite on these bytes.
My config is
Full UART [Tx +Rx]
clock selection -> internal clock
Rx Address Config -> Add Mode -> Software Byte by byte
->Add# 1 & 2->0
Break signal bits->12
Enable 2 out of 3 voting per bit
Rx & Tx buffer size 30 Bytes
oversampling rate -> 8x
how can i recieve all 30 bytes as it is in Rxbuffer?
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, if you do not have multiple devices on a serial bus, you should disable all that addressing features of the UART which may interfere with your needs.
When using the buffer mechanism the interrupt for receiving a byte is disabled, thus leaving you only the method to poll for a message received or to look for any bytes already in the buffer. I assume you are reading bytes off the FIFO whichs size is 4 so getting your incomplete data. You will have to read the data off the buffer with UART_GetChar() while querying with UART_GetRxBufferSize() for data received.
To give you furter help, it is advisable to upload your project here, using the "Create Workspace Bundle"-command after cleaning the design.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your reply
sir, as per your guideline am polling bytes from buffer & querying with UART_GetRxBufferSize() for data received.
but am getting output for once only.whenever am showing card next time the program control is hanging in UART_GetRxBufferSize() in log_in_sector.
so how can i remove this.
also am using Mifare_reader_ClearRxBuffer() in each function, & the data remains in buffer as it is????
is there any mistake in my method of querying for buffersize?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
my project file is attached
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sorry its here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ohhh dont know why the attachment is not uploading
am transmitting 4 bytes by PutArray,
waiting by while(Mifare_reader_GetRxBufferSize()<=4);
recieving 10 bytes by GetChar(),
clearing rx buffer,
then
transmitting 12 bytes,
waiting by while(Mifare_reader_GetRxBufferSize()<=4); <-Here it hangs whenever i shows card next time
recieving 5 bytes,
clearing rx buffer,
then
transmitting 5 bytes,
waiting by while(Mifare_reader_GetRxBufferSize()<=4);
recieving 21 bytes,
clearing rx buffer
printing data
i have made rx & tx buffer size 22 & break signal bits 13.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may send your zipped project-file to my personell address, which is briefe@jmeiersoftware.de., I'll try to upload it to this forum (you're not the only one having problems uploading a file).
From your work you described in your post, there seems to be a transmition going on but some chars seem to get dropped. did you ever try to look at some of the error-bits in the RxStatus()? Note that tese bits are cleared upon a read!.
Debugging while interrupts from hardware become pending sometimes look as if the program refuses to re-start from a breakpoint, so do not let you get confused about that.
I normally do not use BREAKs in UART-transmitions, they are used afaik for keeping a connection open preventing it from beeing dropped because of no traffic occured too long. If you can, do not use break.
A rather simple way of thesting an UART connection is to cross-connect the RXses and TXses and send out in a loop everything you receive. The cross-connect can be made PSoC internally to exclude any additional hardware or later to include driver, cable etc.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Having a look into ypur program reveiled the following:
the function select_card() was processed and you are hanging in log_in_sector()
The reason for that is:
You check the buffer for containing 4 characters and then you're reading off 21 bytes without checking for chars available.
The polling for GetRxBufferSize() is disabling the interrupt for a short time and that's where you are looping. The count of received characters does not match the number of chars you expect.
Since this will always stall your program I would suggest to put all the receive-communication with the Mifare_reader into a single function with a parameter indicating how many chars you expect and as return-value how many chars you received. To keep this function from stalling in a dead-loop I would suggest to set up a timer which you start at entry and that can abort waiting for the chars.
Also, if not really needed, I would suggest to abandon the break-bits.
May I upload your project to the community?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another idea just came up:
I do not know the protocol you are using with the Mifare_reader, but rather often the last character sent by a peripheral is <Cr> or <Lf> which are 0x0d or 0x0a respectively. Will it not be better instead of counting chars receiving chars until a 0x0a or 0x0d occurs?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried your ideas but still bytes were missing.
so i replace buffersize by BufferWrite i.e. now i am checking Mifare_reader_rxBufferWrite .
i think checking Mifare_reader_rxBufferWrite doesnt disable intrupt. so now getting exact output as expected.
thanks.