Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Flashing an LED using SAM7S256... SAM-ICE JTAG problem
PostPosted: Wed Sep 23, 2009 4:08 pm 
Offline

Joined: Tue Sep 15, 2009 4:24 pm
Posts: 2
Further to my last post, since I am not having any luck single stepping through my code, I thought I would download it to the SAM7S256-EK using IAR EW v5.4

My LED does not flash and I cannot work out where I am going wrong. Here is a dump of the Log File:

Tue Sep 22 16:00:19 2009: DLL version: V4.8f, compiled Jul 8 2009 19:54:44
Tue Sep 22 16:00:19 2009: Firmware: J-Link ARM V6 compiled Jun 30 2009 11:04:04
Tue Sep 22 16:00:19 2009: JTAG speed is initially set to: 32 kHz
Tue Sep 22 16:00:19 2009: Initial reset was performed
Tue Sep 22 16:00:19 2009: TotalIRLen = 4, IRPrint = 0x01
Tue Sep 22 16:00:19 2009: Found 1 JTAG device, Total IRLen = 4:
Tue Sep 22 16:00:19 2009: #0 Id: 0x3F0F0F0F, IRLen: 4, IRPrint: 0x1 ARM7TDMI Core
Tue Sep 22 16:00:19 2009: J-Link found 1 JTAG device(s). ARM core Id: 3F0F0F0F ARM7
Tue Sep 22 16:00:19 2009: Device at TAP0 selected
Tue Sep 22 16:00:19 2009: JLINK command: ProjectFile = C:\Documents and Settings\SimonB\My Documents\ARM Stuff\ARM Software\port_toggle2\
settings\port_toggle2_Debug.jlink, return = 0
Tue Sep 22 16:00:19 2009: JLINK command: device = AT91SAM7S256, return = 0
Tue Sep 22 16:00:19 2009: TotalIRLen = 4, IRPrint = 0x01
Tue Sep 22 16:00:19 2009: RTCK seems to be bridged with TCK
Tue Sep 22 16:00:20 2009: Auto JTAG speed: 8000 kHz
Tue Sep 22 16:00:20 2009: 656 bytes downloaded (1.28 Kbytes/sec)
Tue Sep 22 16:00:20 2009: Loaded debugee: C:\Documents and Settings\SimonB\My Documents\ARM Stuff\ARM Software\port_toggle2\Debug\Exe\
port_toggle2.out
Tue Sep 22 16:00:20 2009: Target reset

then after about 5 second, the following is added:

Tue Sep 22 16:00:20 2009: Failed to set breakpoint at 0x00000008
Tue Sep 22 16:00:36 2009: [main] #0
Tue Sep 22 16:00:36 2009: The stack 'CSTACK' is filled to 100% (8192 bytes used out of 8192). The warning threshold is set to 90.%
Tue Sep 22 16:00:36 2009: The stack 'IRQ_STACK' is filled to 100% (256 bytes used out of 256). The warning threshold is set to 90.%
Tue Sep 22 16:00:36 2009: The stack 'FIQ_STACK' is filled to 100% (256 bytes used out of 256). The warning threshold is set to 90.%
Tue Sep 22 16:00:36 2009: The stack pointer for stack 'CSTACK' (currently 0x20202400) is outside the stack range (0x00100000 to 0x00102000)
Tue Sep 22 16:00:36 2009: The stack pointer for stack 'IRQ_STACK' (currently 0x00000000) is outside the stack range (0x00102000 to 0x00102100)
Tue Sep 22 16:00:36 2009: The stack pointer for stack 'FIQ_STACK' (currently 0x60040080) is outside the stack range (0x00102100 to 0x00102200)

and here is the source code:

Code:
#include <AT91SAM7S256.h>

#define LED            (1<<0)   // PA0
#define INPUT_PIN      (1<<1)   // PA1
#define INT_PIN        (1<<2)   // PA2

static void initialize( void);
void delay_us( int time);
void delay_ms( int time);

int main(void)
{
  int delay = 100;
  volatile long input;
  initialize();

  volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA;

  while(1)
  {
    input = pPIOA->PIO_PDSR;          //for debugging.  Watch input variable to check if inputs working.

    if(( pPIOA->PIO_PDSR & INPUT_PIN) == INPUT_PIN)
      delay = 1000;
    else
      delay = 100;

    pPIOA->PIO_CODR = LED;
    delay_ms(delay);
    pPIOA->PIO_SODR = LED;
    delay_ms(delay);
  }
}

static void initialize(void)
{
  //Turn on the peripheral clock.  Without this on, inputs do not actually register in the PDSR register
  volatile AT91PS_PMC   pPMC = AT91C_BASE_PMC;         // pointer to PMC data structure
  pPMC->PMC_PCER = (1<<AT91C_ID_PIOA);            // enable Timer0 peripheral clock

  volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA;
  pPIOA->PIO_PER = (LED | INPUT_PIN);         // Set PIO to control LED and button.
  // Initialize Input
  pPIOA->PIO_ODR = INPUT_PIN ;                // Disable outputs for INPUT pins. (not needed as all pins default input on reset)
  pPIOA->PIO_PPUER = INPUT_PIN;               //Pullup Enable (not needed as all pullups are enabled on reset)

  // Initialize Output
  pPIOA->PIO_OER = LED;                      // Enable output for LED.
  pPIOA->PIO_SODR = LED;                     // Turn LED off.
  pPIOA->PIO_PPUDR = LED;                    //Pullup disable
}

void delay_us(int delay)
{
  while(delay--)
  {
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
      __asm ("NOP");
  }
}

void delay_ms(int delay)
{
  char i;
  while(delay--)
  {
    for(i=0; i<4; i++)
    {
      delay_us(250);
    }
  }
}


Any thoughts would be greatly received

Thanks in advance


Top
 Profile  
 
 Post subject: Re: Flashing an LED using SAM7S256... SAM-ICE JTAG problem
PostPosted: Fri Sep 25, 2009 5:40 pm 
Offline

Joined: Thu Mar 02, 2006 1:32 pm
Posts: 127
Location: Switzerland
Hi Simon

It sounds as though you may not be loading the code correctly (are you trying to run in FLASH or in SRAM). Or the start up file is not correct (?)

It may be best to first take a demo project as delivered with EWARM 5.4 suitable for the chip that you have and test that. Try running in SRAM and FLASH (the project will probably have both targets).

Assuming all goes well, make a copy of the project and add your code in place of the demo's main. You should then be sure that things are getting that far and can concentrate on your code.

Regards

Mark

http://www.uTasker.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: