EmbDev.net

Forum: ARM programming with GCC/GNU tools Amtel at91sam7s256 example needed!


Author: Kam (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi all,

I'm having a real pain in the ass trying to just READ a button input
from the Olimex at91sam7s256 proto board!

Here is the simple code!

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

#define output_low(mask)    (pPIO->PIO_CODR=mask)
#define output_high(mask)   (pPIO->PIO_SODR=mask)
#define input(mask)         (pPIO->PIO_PDSR & mask)
//#define input(mask)         (pPIO->PIO_ODSR & mask)

#define HIGH    1
#define LOW     0

int main()
{
    int x;

    LowLevelInit();

    // Set up the LEDs
    pPIO->PIO_PER=LED_MASK|SW_MASK;     // bits 17,18 | 19,20
    pPIO->PIO_OER=LED_MASK;             // bits 17, 18
    pPIO->PIO_SODR=LED_MASK;            // bits 17, 18

    pPIO->PIO_ODR=SW_MASK;
    pPIO->PIO_PER=SW_MASK;


    // turn off LEDs
    output_low(LED1);
    output_low(LED2);

    while(1)
    {
        if(input(SW1)!=LOW)
        {
            output_high(LED1);
            output_low(LED2);
        }
        else
        {
            output_low(LED1);
            output_high(LED2);
        }
    }

    while(1);

    return 0;
}


Any thoughts?!

~Kam (^8*

Author: Kam (Guest)
Posted on:

Rate this post
0 useful
not useful
Got it!

I was missing the following line in the init...

    pPMC=AT91C_BASE_PMC;

    //enable the clock of the PIO
    pPMC->PMC_PCER = 1 << AT91C_ID_PIOA;


~Kam (^8*

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.