I tried both programs on a Atmega1284p. Both worked in programming the information but failed to read for verification purpose.
On the AVR data sheet, it mentions that data is clocked on rising edge during write and falling edge during read. Could that be the problem? How do I make sure?
Thanks.
Hey qiangbo,
First of all, the data clock edges shouldn't really come into play here since this is basically acting as an ICSP programmer, and so all of the hardware specifications are handled through the SPI port of the mBed.
I just took a brief look at the datasheet for your Atmega1284p. It should be noted that when I wrote that code I had the very specific objective of programming an Atmega8 for use in a USBasp programmer (http://www.fischl.de/usbasp/) and so I hard-coded the lock and fuse bits according to my needs. Thus, I'd ask that you set edit these lines:
00206 write_lock_bits(0xFF); //1111 1111
00207 write_fuse_bits(0x62); //0110 0010
00208 write_fuse_bits_high(0xDF); //1101 1111
00209 write_extended_fuse_bits(0xF9); //1111 1001
to the defaults as listed in your Atmega1284p datasheet (or to whatever settings you need) (pp. 291-293 http://www.atmel.com/dyn/resources/prod_documents/doc8059.pdf).
Also, as mentioned in the program description the page size should be changed:
00013 #define MAX_PAGE_SIZE (64 >> 1) //divide max page size by 2 to get number of words per page
(change the 64 to 256 for your particular microcontroller).
Lastly, I'd ask for a copy of your code, since I realize my code has the read functionality but does not actually exercise it in the published version.
Cheers and good luck,
Chester Hamilton
Note: I wrote this back when I was relatively new to programming, so I realize the code isn't the most readable, but I'm willing to help if you have any further issues/questions.
I'm thinking of building a project with a very large number of LEDs and so I'm looking into using ATtiny chips as controllers for groups of them. I don't have much equipment outside of my mbed and I've been looking into building a USB ATmega/ATtiny programmer (something like this) but it occured to me, I alreday have an mbed!
Could an mbed program be written to program ATMEL (or even PIC) chips? This'd be a huge save in money for myself but also for loads of new hackers and makers who would look to the mbed as the device that does it all.
I'm about to make an order from Farnell so if anyone out there has suggestions as to which ATtiny etc. I should start with I'll order and try and write a program like this staright away!
Great to see some of the mbed team at the Maker Faire UK, thanks for all your hard work!