Programing using the Usbasp
After deciding to build the Ambika synthesiser most of the construction seemed fairly straight forward from the outset. The only thing that bothered me about it and the main thing that I was unfamiliar with was the use and particularly the programing of the atmega chips. After a large amount of reading on the internet I seemed to have got enough information and learning behind me to enable me to have a go. The Ambika uses two types of atmega chips, the atmega644 is used on the main controller PCB and the atmega328 is used on each voice card.
To program the atmega chips I bought a 5V / 3.3V USBASP Programmer Adapter w 10 Pin Cable Usbasp from Amazon, this came with a 10 way IDC connector and cable. I wanted to try and program the atmega644 on its own away from the main PCB so I built a Vero board with a 40 pin socket and a 10 way IDC connector for the cable to plug into. There are only six wires from the IDC connector to the 40 pin DIL socket but you also need to link up pin 31 to ground.
IDC connector pin 1 to atmega pin 6 MOSI
IDC connector pin 2 to atmega pin 10 VCC
IDC connector pin 5 to atmega pin 9 RST
IDC connector pin 7 to atmega pin 8 SCK
IDC connector pin 9 to atmega pin 7 MISO
IDC connector pin 10 to atmega pin 11 GND
IDC connector pin 10 to atmega pin 31 GND
Installing the Usbasp driver on windows 10
Using Windows 10 is not that straight forward to get the driver working. You can download it but Windows 10 won’t let you install it. You will get the message
“the third party INF does not contain digital signature information”
To get around this you have to restart Windows while holding the shift key. It will restart with a blue screen with the message
“Choose an option”
Click on troubleshoot
Then click on advanced options
Then click on start-up settings
Then click on restart
Then press number 7 which will disable driver signature enforcement
Windows will then re-start and you will now be able to go to device manager and right mouse click on Usbasp and update driver, and then select
“Browse my computer for driver software”
And click on the browse button to where the driver has been saved.
The driver will then be installed.
After that you need to install winAVR and select all components when asked. This will install a few different applications but the one we are interested in is winAVR.
This is what we will use to program the atmega644. WinAVR is a command prompt application so once it is installed, press the Windows button and type
Then press enter to open the commend prompt screen.
avrdude –c usbasp –p m644p
This will check the board is connected and it is reading the atmega644p.
You should get back a message like the one below.
Ignore the message about "warning: cannot set sck period. please check for usbasp firmware update." Everything s connected ok and the programmer has read and identified the atmega 644p as being present and correct.
To program the chip, copy the hex file ambika_controller.hex, into the user folder on drive C with your name on.
If this sounds confusing its so you can use the CMD prompts exactly as they are shown below. Copy the downloaded files to your account user folder on the C drive.
avrdude -B 100 -V -p m644p -c usbasp -P usb -e -u -U efuse:w:0xfd:m -U hfuse:w:0xd2:m -U lfuse:w:0xff:m -U lock:w:0x2f:m
avrdude -B 1 -V -p m644p -c usbasp -P usb -U flash:w:ambika_controller.hex:i -U flash:w:ambika_controller_boot.hex:i -U lock:w:0x2f:m
You should get back something like the picture below.
You will still get the warning messages about not being able to set the SCK period but you will see the atmega644p get erased, the hex code will then get written and then it will do a verify to check it's been written correctly. You should now have an atmega644p programmed and ready to be plugged into the Ambika controller board.
ISP programming the ATmeg328P
Having successfully programed the Atmega644 I was going to do the same process to program the Atmega328, however I changed my mind due to a couple of things. Firstly I felt more confident having got the Atmega644 working so I thought I’d give ISP programing a go.
If you are unfamiliar with this it basically means that you program the Atmega while it is in circuit. This appealed to me because there are six voice cards so it would have meant a lot of plugging and unplugging. As you are programing “in circuit” they need to be powered up as well so it made sense to build the voice cards and plug them all in to the Ambika motherboard.
The Usbasp comes with a ten way IDC but the standard ISP configuration and the one on the Ambika voice card is a six pin one. Luckily as it is standard you can easily find ten pin to six pin adapters very cheaply. If you struggle I’ve put a link below to Amazon.HiLetgo 10pcs 10 Pin Convert to Standard 6 Pin Adapter Board For ATMEL AVRISP USBASP STK500
The most important thing to remember when doing ISP is to alter the jumpers on the Usbasp programmer. When you use it to program out of circuit like I originally did by using the Vero board, the Usbasp provide the power. Either 5V or 3.3V, when the Atmega is in circuit it receives its power from the Ambika mother board so you have to set the jumper accordingly. In this case you just remove it, remember to keep it somewhere safe as it’s tiny and easy to lose.
With ISP you don’t’ need any other software that you haven’t installed previously to program so all the commands from the first part of this article are still relative.
You need to download the files.
Put these in your account folder in “user” on the C drive so you don’t have to alter the CMD prompts.
avrdude –B 100 –V –p m328p –c usbasp –P usb –e –u –U efuse:w:0xfd:m –U hfuse:w:0xde:m –U lfuse:w:0xff:m –U lock:w:0x2f:m
avrdude –B 1 –V –p m328p –c usbasp –P usb –U flash:w:ambika_voicecard.hex:i –U flash:w:ambika_voicecard_boot.hex:i –U eeprom:w:ambika_voicecard_eeprom_golden.hex:i lock:w:0x2f:m
As you will notice it similar to what we did before but with different files and with m328 because of the different Atmega this time. When the programing is complete you will see each voice board come to life as the two LED’s light on the voice card once it’s programed.