UART Implementation

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
romac_285831
Level 2
Level 2

 Hi ,

   

I want to use UART user module.

   

I want to send 4 bytes of data from PC to PSOC. 

   

PSOC when receive should send 2 bytes of data back.

   

I will use a 4 byte array for rx buffer and 2 byte array for tx buffer.

   

When 4 bytes data is received interrupt should occur.

   

How can i implement it 

   

 

   

regards

   

Rocky

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Frankly : you cannot.

   

An Interrupt can be generated at the receive of EACH character since interrupts in PSoC 1 are related to hardware.

   

I would suggest to have the number of incoming characters counted (after retrieving and storing them) and when your treshold (or a pre-defined sequence) is reached you set a flag (a global variable) that you inspect in your main-loop and, if set react accordingly (or just inspect the count).

   

 

   

Happy coding

   

Bob

0 Likes
Anonymous
Not applicable

 I normally use a ring buffer, all data receive would be queue up in the ring buffer and the main loop inspect the head and tail pointer. 

   

if you know the total number of bytes is a fix number, then just do the decoding when the number of bytes received, and if that is correct then send the bytes out.

0 Likes