Banner with yellow background
Tuesday, 27. May 2008
Sorting Out Page Sizes

There is a new release of AVRISP Emulation for Arduino. This is an Arduino firmware that allows you to program other AVR microcontrollers.

The new zip file (avrisp.01.zip) should compile on the current Arduino IDE, and I changed the comments that put the wrong labels on the SPI pins. Go ahead with this file if you use Tiny13, Tiny2313 etc. (any AVR with a 32 byte/16 word page size)

I'm building an Arduino for William on the Evil Mad Scientist business card. Monday I added the six pin ISP port to the card and built a cable for it. I took a 40 pin IDE cable and cut off one end of it. Then I soldered the other end to a pin header that I could plug into the Arduino.

I thought that my Mega8 chip was damaged because when I flashed it parts of the memory were not written. I tried using a fresh Mega168 chip and got similar results, so I took a second look at the software. When I developed the Arduino AVRISP emulation I was using chips with a 16 word page size. That means you write the flash 16 words (32 bytes) at a time. I had hardcoded that page size in my software. But the Mega8 uses a 32 word page size. My software would fill the zero page fine, then skip the bottom of page 1, resulting in the empty memory rows.
I already had the page size (AVRDUDE sends it to the programmer) so I just needed to change a function to return the correct current page based on the page size (instead of the hard coded 16 word page size).

It took some work to figure this all out. I even used Powershell at one point: I was wishing for a list of Atmel AVR chips with their flash page sized, when I realized that all the information is in avrdude.conf. I just had to find a way to summarize it. Powershell select-string saved the day select-string ("description", "paged", "page_size") avrdude.conf.

I saw that the various chips with paged flash use pages from 16 to 128 words, so I updated the current_page() function with the appropriate sizes and bitmasks. I would like to just calculate the bitmask, but with just a handful it was clearer just to return a value based on the current page size.

The updated code works with Mega8 (and should for Mega168 and other AVR Mega chips) and is available in the project SVN.

Creative Commons License (by-nd)

Creative Commons License

Blog entries licensed under a Creative Commons License.

8155 days of detection
mod: 12/3/08, 5:42 AM

days of detection

... PMOG
... ideas
... brain hurts
... weblo

owner

Biography

Randall Bohn lives in Orem, Utah, USA. He works as a Software Quality Engineer. He is a big fan of the AVR line of microcontrollers. He has been in the computer industry since 1989. Randall is married and has three children.

rsbohn can be reached via gmail.com.


status
Youre not logged in ... Login
Amazon.com DVD Shop
menu
... home
... topics
... galleries

... Antville.org home
search

related


calendar
December 2024
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425262728
293031
December
recent updates
Arduino Starter Kit
MAKE Blog How-to Tuesday posted a challenge: Optimize the sketch code for a pressure sensor bar graph. Here is my second attempt: int gate[] = {10, 20, 50, 100, 200, 32767}; void setup() {DDRB = 0b00111110;} void loop() { int dval = 0; int rval = analogRead(2); for (int x = 0; rval...
12/3/08, 5:42 AM
Measuring Supply Voltage
I'm running my latest handheld computer on solar power. It starts up when the sun rises and runs all day. I started wondering how I could measure the voltage coming in from the solar panel. I came up with a way to use a diode and a resistor and the...
7/29/08, 9:53 AM
Ten Pin ISP adapter
I've already built a six pin ISP adapter, but my Olmex cards use the ten pin ISP. I put a header on a scrap of perf board, added an LED for the heartbeat, and then connected the ten pin cable. Actually it is a fifteen pin cable, off a joystick...
7/16/08, 10:00 PM
Hello 5x7 Style
Wrote a new firmware for the 5x7 display. Now it scrolls out 'hello' over and over again. I'm running it on a solar panel, so it wakes up with the sun and runs all day long. When I built the LED matrix I put resistors on the five columns. I'm starting...
6/17/08, 12:48 PM
Provo, Utah
With a walkable downtown and access to two Universities, Provo Utah is a great location. I live next door in Orem. Kipplinger: Provo: Pristine Tech Mecca (Video) (Text)
6/2/08, 10:07 AM
Another release of AVRISP sketch
There is a new release of the AVRISP emulation sketch for Arduino: avrisp.02.zip. This one should work with Mega8 and Mega168. mega-isp
5/28/08, 4:48 PM
Sorting Out Page Sizes
There is a new release of AVRISP Emulation for Arduino. This is an Arduino firmware that allows you to program other AVR microcontrollers. The new zip file (avrisp.01.zip) should compile on the current Arduino IDE, and I changed the comments that put the wrong labels on the SPI pins. Go ahead...
5/27/08, 11:31 AM
Flash Problems
I'm building a project using the AVR ATMega8 microcontroller. Once I got the thing wired up to where I could write firmware to it I found that it was always failing. I made a .hex file full of 0x10 values (256 bytes worth) and tried uploading that to the chip....
5/16/08, 2:56 PM
William's Arduino Board
I'm building an Arduino-compatible board for William. I'm building it on the Evil Mad Scientist MegaXX8 business card. It will have four built-in LEDs and a USB interface. It will also have connectors so he can use it with a breadboard. Perhaps we can connect it to some of his...
5/15/08, 7:26 AM
Cybord Signal Detector
Some digital radio signals use Frequency Shift Keying (FSK). This often has one frequency for a Mark and one for a Space. I plan to build a cybord or other chip that will decode an FSK signal, producing three different values: NO_SIGNAL, MARK, and SPACE. The signals would then go...
5/15/08, 7:20 AM

destinations

Listen to IT Conversations



Made with Antville

Quantum Touch

RSS Feed