2010年10月10日 星期日

AVR JTAG Debugger/Programmer

http://www.avrportal.com/?page=jtag

AVR JTAG : Credit to IsoJtagIsp for schematic and bootloader. I've been modified a schematic from IsoJtagIsp by remove USB interface from schematic because I'd like to use AVR JTAG with USB2RS232 and serial port.
















AVR JTAG schematic.

    Download bootloader onto ATMEGA16, If you don't have a AVR programmer I recommended a simple
programmer from Ponyprog, because Ponyprog need a few component for build a AVR programmer. If you already have a AVR programmer you can use it to download bootloader. If you're using Ponyprog the fuses should look like this.


Configuration bit.
    Once the bootloader is programmed, the next step is upgrade JTAGICE firmware onto ATMEGA16 by using AVR Studio
  • Set jumper to JTAG mode and powered to the board, then the Power LED should come on and Act LED should be blink.
  • Open AVR studio select Tools menu and select AVR Prog, AVR Prog connected with AVR JTAG look like this.

AVR JTAG firmware upgrade.
  • Click on Browse button and choose AVR JTAGICE firmware for upgrade like C:\MCU\Atmel\AVR Tools\JTAGICE\Upgrade.ebn
  • Click Program button and wait until upgrading complete.
  • Reset board by press reset button and wait until Act LED stop blink.
  • Return to AVR studio, select Tools menu->Program AVR->Connect, if firmware upgrade complete you can see JTAG ICE dialog look like this.




Upgrade OK
  • Testing AVR JTAG with ATMEGA32, Pin connection between AVR JTAG and MEGA32 such as

    • TCK_SCK -> TCK
    • TDO_MISO -> TDO
    • TMS_RST -> TMS
    • TDI_MOSI -> TDI
    This is a simple source code for testing JTAG, If you don't have compiler you can download WinAVR from winavr.sourceforge.net it's free compiler. After WinAVR installed, create new project in AVR studio by select Project menu->New project, then you can see Create new project dialog, select AVR GCC in Project type, fill project name you want to create into Project name box, fill main into initial file box, final click finish button and put this code into main.c.

Code:
/***********************************************************************
*
* File  : main.c
* Desc  : Blink LED on PB0
* Compiler : AVR GCC
* Author  : Jirawat Kongkaen
* Website  : .
*
***********************************************************************/
#include 
void delay(unsigned int delay);
int main(void)
{
 DDRB = 0xFF; // Port B as out put
 for(;;)
 {
  PORTB |= _BV(PB0);
  //delay(50000);
  PORTB &= ~(_BV(PB0));
  //delay(50000);
 }
 return 0;
}

void delay(unsigned int delay)
{
 while(delay) delay--;
}

Before start debugging you have to compile main.c first by select Build->Build or press F7 on keyboard, now let start debugging by select Debug menu->Start Debugging of click Start Debugging button, look like this.

Start debugging.
    Connection between AVR JTAG and ATMEGA32 is connected (see below figure), Now let's start debugging by click Step into button or press F11, LED at PB0 will come On/Off.


 
    Testing had finished and you can use AVR JTAG for debug/program AVR microcontroller. I will explain about how to AVR JTAG working, if you set JP1 to JTAG mode and power on the board, AVR JTAG wait for firmware upgrade until Act LED come off, You can upgrade firmware at this sequence. After Act LED com off AVR JTAG ready to use. If you set JP1 to ISP mode you should be able to program:


Bread board with AVR JTAG and ATMEGA32


Completed board.

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。