[En-Nut-Discussion] Nut/OS I/O register access on sam9260

Artur Funk a_funk80 at yahoo.de
Mon Jun 9 18:16:01 CEST 2008


Hello, my name is Artur and i come from Berlin/Germany. Sorry for my dummy english but i will try to describe my problem by the best way. I am new with ARM µC an Nut/Os and this ist my first try. I have allready installed Eclipse with yagarto and the sample project works fine. I tried the LED example and ist was very easy to setup this project on a olimex sam9260 board. Now i want to try to read some pins. I this case i want use the user button which is connected to PORTC and Pin15 (with a pull-up on board). The register access happents with inr see my code:

#include <compiler.h>
#include <cfg/os.h>
#include <stdio.h>
#include <io.h>
#include <dev/board.h>
#include <sys/thread.h>
#include <sys/timer.h>
#include <sys/event.h>
#include <dev/twif.h>
#include <dev/irqreg.h>

void Led1Off(void)
{
    outr(PIOA_OER, _BV(6));
    outr(PIOA_SODR, _BV(6));
    NutSleep(50);
}

void Led1On(void)
{
    outr(PIOA_OER, _BV(6));
    outr(PIOA_CODR, _BV(6));
    NutSleep(50);
}

int main(void)
{
    u_long baud = 115200;
    unsigned int val;

    /*
     * Register the UART device, open it, assign stdout to it and set 
     * the baudrate.
     */
    NutRegisterDevice(&DEV_DEBUG, 0, 0);
    freopen(DEV_DEBUG_NAME, "w", stdout);
    _ioctl(_fileno(stdout), UART_SETSPEED, &baud);

    printf("\n Nut/OS Version: %s", NutVersionString());
    printf("\nCPU running at %lu Hz", NutGetCpuClock());
    puts("\nProgram loaded...\n");
    

    
    for(;;) 
    {
        Led1On();
        Led1Off();
        
        val = inr(PIOC_PDSR);     
        val = (val & 0x8000);
  
        if(val) 
          {
             puts("\n Button pressed");
             printf("\n Value: %i", val);
          }
    }
}

The code gets compiled without of any errors but the button seems to be pressed allways. Can me help someone and tell me what problems they are? 

Further i want access 8 Bits from left side of portB (31 down to 24). Can somebody provide me some examples, how to read more as one bit of a port at the same time and to write to this at the same time?

Thx u all.



      __________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com


More information about the En-Nut-Discussion mailing list