Thursday 23 August 2012

AVR PORT control via RS232 and C# GUI

I was surprised how simple this was.  I have been studying Visual C++ for sometime and this project would be very difficult to achieve using that.  With C#,however, it is very simple and this interface can be knocked up in a couple of hours.  (This is actually the first time for me to use it!).  If you have previous experience with Visual Basic it is useful with the controls etc.

The following is a capture of the logic analyzer and the GUI.


The logic analyser is a34 channel LogicPort which I find really useful.  You can see that it has an interpreter attached to both the transmit and receive to show the ASCII character in the frame.

The AVR code is set up using interrupt control of the USART to transmit and receive.  It receives one byte from the serial port and assigns it to PORTA, which is connected to the LEDs on the STK500 board.  It then reassigns the same value to the UDR register which will fire the transmit interrupt to echo back to the program on the PC.  The STK500 is not shown but as we select each check box in the video below the appropriate LED goes on/off.  The video starts by showing how you select the serial port and the exception handling of the C# program.



The following is the C code for the AVR (mega32 in this case).  For simplicity I have not shown the seperate files but the Usart init is in its own header file..



No comments:

Post a Comment