Interruupt code doesn't seem to work for SAM7-EX256

Hello friends,

I wrote sample code for SW1(button1) , SW2(button2) , Joystick of SAM7-EX256…My code doesnt seem to work but compiles successfuly…Here is my code snip(If some one needs then I can send them the complete project)…Please help me I am Stuck!!


AT91PS_PIO m_pPioA = AT91C_BASE_PIOA;

AT91PS_PIO m_pPioB = AT91C_BASE_PIOB;

int get_key( void )

{

if( !( ( m_pPioA->PIO_PDSR ) & BIT7 ) ) {

return( LEFT_KEY );

}

if( ! ( ( m_pPioA->PIO_PDSR ) & BIT8 ) ) {

return( DOWN_KEY );

}

if( !( ( m_pPioA->PIO_PDSR ) & BIT9 ) ) {

return( UP_KEY );

}

if( !( ( m_pPioA->PIO_PDSR ) & BIT14 ) ) {

return( RIGHT_KEY );

}

if( !( ( m_pPioA->PIO_PDSR ) & BIT15 ) ) {

return( CENTER_KEY );

}

// check button SW1

if( !( ( m_pPioB->PIO_PDSR ) & BIT24 ) ) {

return( BUTTON1 );

}

// check button SW2

if( !( ( m_pPioB->PIO_PDSR ) & BIT25 ) ) {

return( BUTTON2 );

}

return( NO_KEY );

}

.

.

.

extern void LowLevelInit(void);

int main( void )

{

// Initialize the Atmel AT91SAM7S256 (watchdog, PLL clock, default interrupts, etc.)

LowLevelInit();

// Set up the LED (PA3)

volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA; // pointer to PIO data structure

pPIO->PIO_PER = LED_MASK; // PIO Enable Register - allow PIO to control pin PP3

pPIO->PIO_OER = LED_MASK; // PIO Output Enable Register - sets pin P3 to outputs

pPIO->PIO_SODR = LED_MASK; // PIO Set Output Data Register - turns off the LED

// Initialize SPI interface to LCD

InitSpi();

// Init LCD

InitLcd();

// clear the screen

LCDClearScreen();

LCDPutStr(“Starting”, 115, 10, SMALL, BLACK, YELLOW);

int i=0;

int number[0];

while( 1 ) {

number[0]++;

Backlight(0);

if ((number[0]==1600))

{

Backlight(1);

LCDClearScreen();

LCDPutStr(“NUMBER”, 115, 10, SMALL, BLACK, RED);

Delay(1000000);

number[0]=0;

Delay(1000000);

}

switch( GetKey() ) {

LCDClearScreen();

case 0:

LCDPutStr(“LEFT KEY”, 115, 10, SMALL, BLACK, YELLOW);

break;

case 1:

LCDPutStr(“CENTER KEY”, 115, 10, SMALL, BLACK, RED);

break;

case 2:

LCDPutStr(“DOWN KEY”, 115, 10, SMALL, BLACK, YELLOW);

break;

case 3:

LCDPutStr(“UP KEY”, 115, 10, SMALL, BLACK, RED);

break;

case 4:

LCDPutStr(“RIGHT KEY”, 115, 10, SMALL, BLACK, YELLOW);

break;

case 5:

LCDPutStr(“BUTTON1 KEY”, 115, 10, SMALL, BLACK, RED);

break;

case 6:

LCDPutStr(“BUTTON2 KEY”, 115, 10, SMALL, BLACK, YELLOW);

break;

default:

LCDPutStr(“NOthing”, 115, 10, SMALL, BLACK, YELLOW);

break;

}

}

you are not supposed to call “LowLevelInit”, it’s automatically called inside the startup assembly code

you are not using interrupts… where is your interrupt routine and setup?

did you enable the peripheral clock for PIO?

Hello Frank,

Sorry to trouble you again, I am very new to ARM programming and I really dont understand what you meant by following lines…

I have attached my complete project in this thread and please could you point me out when I have done wrong?? It will be great help for me to proceed further…If you could give me some sample snap of code / sample codes for sam7-ex256 that will be great help…

My project is uploaded in google doc also…

https://docs.google.com/leaf?id=0Bzynas … NDRm&hl=en

Thanks in advance…

frank26080115:
you are not supposed to call “LowLevelInit”, it’s automatically called inside the startup assembly code

you are not using interrupts… where is your interrupt routine and setup?

did you enable the peripheral clock for PIO?

Hello Frank,

I could rectify the issue!! And you were right about Interruput handler setup!!!

I followed the ARM7TDMI documentation and could identify what you mean…

Thanks a ton for the help…

injioncloud:
Hello Frank,

Sorry to trouble you again, I am very new to ARM programming and I really dont understand what you meant by following lines…

I have attached my complete project in this thread and please could you point me out when I have done wrong?? It will be great help for me to proceed further…If you could give me some sample snap of code / sample codes for sam7-ex256 that will be great help…

My project is uploaded in google doc also…

https://docs.google.com/leaf?id=0Bzynas … NDRm&hl=en

Thanks in advance…

frank26080115:
you are not supposed to call “LowLevelInit”, it’s automatically called inside the startup assembly code

you are not using interrupts… where is your interrupt routine and setup?

did you enable the peripheral clock for PIO?

Hey I was wrong about the LowLevelInit being called by the startup assembly code, your startup code is different from what I use.

Try using at91lib provided by Atmel, the API will make everything easier.

http://www.atmel.com/dyn/products/tools … ol_id=4343