Showing posts with label C programming. Show all posts
Showing posts with label C programming. Show all posts

Sunday, August 1, 2010

C code: Some weirdness with 'strcmp' when using Interrupts with UART

Below is an excerpt from the post I put on AVR Freaks under AVR Forum about this weird problem involving the 'strmp' library function. This was burning my metallic butt all week. I have a simple workaround to continue coding for now. The complete post with test code and display output can be see at this [link] If you night have any suggestions feel free to post here or on AVR Freaks.
I posted a problem about 'strcmp' in another post earlier today. I programming our robot to use a command line interface to accept commands over the serial port. This is wired to usart1 on a ATMega128 on a Olimex AVR-MT-128 controller with a DB-9 onboard.

Below is each test code and output showing that I get two diff results when using 'strcmp'. I don't know why this is happening.
Basically, 'strcmp' is supposed to return a 0 when the compare is true. This does happen when using 'fgets' to enter a string.

But in my other test code, where I use interrupts on the usart, the 'strcmp' *does not* return a 0 when the compare is true. Instead, it returns a 13. So I had to edit my test code in order to get it to work.

I hope somebody knows about this. In the meantime, I have to use '13' instead of '0' when using 'strcmp', this is how I have to get my robot to work properly.

Thursday, July 29, 2010

Great Tutorial on programming the Atmel AVR - using Timers

Here's a great tutorial on programming the Atmel AVR microntrollers on using Timers. This is a very in depth and informative instruction. It provides a lot of the details and sample code on how to program the Timers in all the different ways that are possible.

This is found the largest forum for AVR microcontrollers , AVRFreaks.com

More Tutorials on C programming for the AVR microcontrollers is here

=Dan Roganti