Friday, March 18, 2011

In the midst of writing serial I/O code

I hooked up the ATMega328P to my STK600 yesterday and as you can see by this report, I'm running out of Data (RAM) room fast. I will need to use another 500 bytes at least so I will be using almost all of the 2k max size available.

I'm in the midst of writing the serial I/O routines for the AVR. I'm creating "small" buffers both for transmitting and receiving on the serial port. I say small because they are only about 256 bytes each but that is 1/8 of my total RAM size on this AVR. The receive buffer is necessary because I can't predict when serial input will come in and I need to capture it inside a serial interrupt handler. The transmit buffer though... I'm not so sure I really need it. My thinking is that I may need it because I may have a bunch of log strings I need to send but I may not be able to wait for each byte to be sent before the next vsync comes in, so I need a way to buffer outgoing messages and send them a byte at a time between vsyncs.

But it could be that my buffering routines are just as slow as sending each byte to the serial port and waiting for it to be sent. I will need to calculate this.

One thing that is troubling me is how sophisticated the serial code that I'm writing for the AVR is. It is complicated enough that the chance for defects is pretty good and using my traditional debug methods won't be feasible, or at least it will be less feasible. So I need to find a better way to validate my code without actually having to run it on real hardware.

No comments:

Post a Comment