problem with USART interrupt on codevision

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello, btw i have some problems about USART interrupts on codevision....i don't understand how to use interrupts on both TX and RX generated by its codewizard (the buffering one) , and is it possible to create a custom RX and TX interrupts code just like winAVR? and if it is possible, how to do that?

actually i just want to create a code that will interrupt the system when receiving a request packet from outside and then send the requested packet to outside of the system...and i think by using buffer it will just delay the packet that is about to send by putting it into a buffer first and it will remain in that buffer until it is pulled out by the same instruction again....

before that, thx for the help :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just use the regular putchar() and getchar() (and all the other functions like gets() and printf().

You can check if there are any received chars pending by inspecting rx_counter first.

Look at what you actually want to do. e.g. receive a whole line, N bytes, magic byte, ...
And then use the standard library functions.

Of course you can always mimic some of the avr-gcc abortions that are often presented here.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thx for the reply... :D

but how do you inspect the rx_counter?
after some searching on this forum, i found an example on how to use that rx_counter :

#define kbhit()    (rx_counter != 0)  

i used it to make a serial loopback on main loop:

if(kbhit()) {putchar(getchar())};

it worked well but when i tried to make another serial loopback program (i used 2 USART) :

if(kbhit()) {putchar(getchar())};
putchar1(getchar1());

the first line didn't output the character...the program seems like giving higher priority to the second line so the first line couldn't output the loopback...

and can you help me give some examples on how to use tx interrupt on codevision?