In the last entry, I set up a buffer based ATTINY2313 serial file. In this quick tidbit of code, I implement, using that code, a theoretical implementation of a checksum based serial communication.
Here's the idea - the master gives the slave, our ATTINY2313, a random byte between 0 and 255 (exclusive). It inverts that byte and returns it. It then waits for a SUCCESS or FAIL byte (decided by the implementer). This inversion is a checksum - if the master or the slave are not in sync, the slave would not return the correct checksum, telling both that they need to clear their buffer commands and start over and sync back up.
The modified Serial.c after the jump.
Showing posts with label AVR. Show all posts
Showing posts with label AVR. Show all posts
Monday, March 15, 2010
Sunday, March 14, 2010
AVR Serial Buffer - March Madness Entry 14
A little while back, I finally got the USART working on the ATTINY2313. Tonight I managed to adapt buffer code to the device.
The point of the buffer is to allow a host to send a series of commands and let them back up, so that the slave (the ATTINY2313) can deal with the commands as it can. This works best in a one directional setup, where the majority of the information being processed is the master talking to the slave. I will confirm that this works fine for some robotic applications, however. In retrospect I should have used a different system, as that was a robot that mapped an area and returned a heavy amount of data - but it still worked.
In my example, it would wait for 3 bytesCode after the jump.
The point of the buffer is to allow a host to send a series of commands and let them back up, so that the slave (the ATTINY2313) can deal with the commands as it can. This works best in a one directional setup, where the majority of the information being processed is the master talking to the slave. I will confirm that this works fine for some robotic applications, however. In retrospect I should have used a different system, as that was a robot that mapped an area and returned a heavy amount of data - but it still worked.
In my example, it would wait for 3 bytesCode after the jump.
Thursday, March 11, 2010
ATTINY2313 Serial - March Madness Entry 11
At the micro controller study group, I decided to dedicate myself to getting a serial library that works on the AVR ATtiny2313 micro controller. I've used the serial ports on ATtiny25/45/85's, Atmega48/88/168/328s, and Atmega644s, etc... But the ATtiny2313 has a weird set of registers for serial port. Since I planned on using it later with a serial application, I realized that I would have to heavily adjust some of my code due to the 2313's odd choice in register names.
This code should work. Please note that the receive interrupt echoes the input - probably a good idea to change that if you're using it for an application.
This code should work. Please note that the receive interrupt echoes the input - probably a good idea to change that if you're using it for an application.
Wednesday, November 18, 2009
STK500 is fried. I admit, I teared up a little.
Power surge- fried my STK500. The fuse is smoking any time I plug it in and switch it on. I'm shopping for a new fuse, but the markings were burned out. According to some helpful STK500 owners in the IRC chat #avr on the Freenode Network, the markings on the chip read ST label: C525, with an ST center top, ME in the middle, E at right top, and C525 center bottom. A quick search turns up (surprising, since I expected no hits) that the smoking bandit is a slow blow fuse, rated for 24V (makes sense since the power plug is rated 10-15 V) @ 6 Amps.
6 Amps?! How the hell did I blow this thing!?
Anyway, I'm buying a new fuse - the 6A one and a similar 2A one (smallest I could find that was a slow blow @ 24 V). Let's hope this can resurrect one of the most useful tools in my arsenal.
EDIT: It appears that the broken component might be the chip next to it - a bridge rectifier. Easy fix. I ordered LadyAda's USBtinyISP since the STK500 can still be used as the best target board ever (for every AVR). I should have it next week. I'll still try to repair the board, of course - it's a backup plan.
6 Amps?! How the hell did I blow this thing!?
Anyway, I'm buying a new fuse - the 6A one and a similar 2A one (smallest I could find that was a slow blow @ 24 V). Let's hope this can resurrect one of the most useful tools in my arsenal.
EDIT: It appears that the broken component might be the chip next to it - a bridge rectifier. Easy fix. I ordered LadyAda's USBtinyISP since the STK500 can still be used as the best target board ever (for every AVR). I should have it next week. I'll still try to repair the board, of course - it's a backup plan.
Tuesday, November 17, 2009
AVR to Ethernet
Not an uncommon project - I am trying to get an 8-bit AVR Atmega168 online. I'm using the notes found from others' previous projects to guide me. Ultimately I want to create a simple cut and paste module to be able to cheaply include internet capability to a number of other projects - more to come on those in the future.
Here's a quick pick of the ENC28J60 and Magjack (with Sparkfun breakout board to make my life easier.
Unfortunately I'm finding I overlooked ordering key components, so I'm not sure if I'll get it up and running by this weekend. I'll be working getting the basic, ping-able server up and running on AVR tonight . I'm hoping my cheap hacking around with the circuit will allow it to still work.
I also feel like a fool - I may have accidentally fried my STK500 (don't ask) and will be without an AVR programmer for awhile - particularly devestating since I'll be teaching a class on AVR programming in the near future.
Here's a quick pick of the ENC28J60 and Magjack (with Sparkfun breakout board to make my life easier.
Unfortunately I'm finding I overlooked ordering key components, so I'm not sure if I'll get it up and running by this weekend. I'll be working getting the basic, ping-able server up and running on AVR tonight . I'm hoping my cheap hacking around with the circuit will allow it to still work.
I also feel like a fool - I may have accidentally fried my STK500 (don't ask) and will be without an AVR programmer for awhile - particularly devestating since I'll be teaching a class on AVR programming in the near future.
Monday, November 9, 2009
AVR class and a Robocode Challenge
I've been quite busy. I've been volunteering BETA testing the new FIRST robotics controller and teaching high school students how to program their robots in Java. I've also been working heavily with people at FUBARlabs to help turn it into self sufficient hackerspace (easier said than done). I've also been helping FUBAR design some classes...
Subscribe to:
Posts (Atom)
