[En-Nut-Discussion] Olimex SAM9-L9260 board
Lars Tore Skau
larstore at gmail.com
Tue Jun 10 14:04:28 CEST 2008
Hello again..
forgot to mention that you need to enable the peripheral clock!
try to add(before your for loop):
outr(PMC_PCER, _BV(PIOC_ID)); //enable peripheral clock
that said, if you really want to read button presses to perform actions, you
should try the pio level change interrupt, or use a timer to scan the
buttons..
- Lars Tore
On Tue, Jun 10, 2008 at 1:18 PM, af_80 <a_funk80 at yahoo.de> wrote:
>
> I doesn' works. Here is the complete code for this example:
> #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(500);
> }
>
> void Led1On(void)
> {
> outr(PIOA_OER, _BV(6));
> outr(PIOA_CODR, _BV(6));
> NutSleep(500);
> }
>
> int main(void)
> {
> u_long baud = 115200;
>
> NutRegisterDevice(&DEV_DEBUG, 0, 0);
> freopen(DEV_DEBUG_NAME, "w", stdout);
> _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
>
> printf("\nNut/OS Version: %s", NutVersionString());
> printf("\nCPU running at %lu MHz", NutGetCpuClock()/1000000);
> printf("\nProgram loaded...\n");
>
> outr(PIOC_PER, _BV(15)); //enable pio control
> outr(PIOC_ODR, _BV(15)); //set pin as input
>
> for(;;)
> {
> if((inr(PIOC_PDSR) & _BV(15)) ? 1 : 0)
> {
> Led1Off();
> }
> else
> {
> puts("\n Button pressed");
> }
>
> Led1On();
> Led1Off();
> }
> }
>
>
> The LED's are blinking all the time but the reading from pin produce no
> action. I tried thes sample also with ext-header connector on port_pin
> pb22
> also not successful :(
>
> I don't know about this problem, maybe Ethernut requires that peripheral
> should be explicit disabled before using of gpio ?
> --
> View this message in context:
> http://www.nabble.com/Olimex-SAM9-L9260-board-tp17717279p17752980.html
> Sent from the MicroControllers - Ethernut mailing list archive at
> Nabble.com.
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
More information about the En-Nut-Discussion
mailing list