|
Hello,
I have a netduino plus board with at91sam7x512 and my goal is to create a simple FreeRTOS application where I have one task which makes a LED turn on if you press the on board button. So far I've tried the sam7x Getting Stared example and it works perfectly fine. I also have the FreeRTOS demos and they work too. BUT when I changed one of the FreeRTOS demos so that it can handle the button interrupts the same way as the sam7x demo - nothing works. I'm almost sure that the problem is in the port. FreeRTOS use one sam7x port and the Getting Started project uses totally different port and additional libraries. I've tried adding this port and additional peripheral classes (pio.c, pio_it.c, led.c) to my FreeRTOS example but it still doesn't work. It compiles but when I run it on my target device nothing happens.
I also spend the last few days investigating how the Getting Started Demo works and I tried to apply the same logic in my FreeRTOS sample: Here is the code which I use to initialize a button:
[code] /* Enable the peripheral clock. */ AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA ); AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << AT91C_ID_PIOB ) ; AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << AT91C_ID_EMAC ) ; unsigned int mask = 1<<29; //the onboard button is at PA29 AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOA; AT91C_BASE_PIOA->PIO_IDR = mask; // Enable pull-up(s) if necessary AT91C_BASE_PIOA->PIO_PPUER = mask; // Enable filter(s) AT91C_BASE_PIOA->PIO_IFER = mask; // Configure pin as input AT91C_BASE_PIOA->PIO_ODR = mask; AT91C_BASE_PIOA->PIO_PER = mask; //enable it AT91C_BASE_PIOA->PIO_ISR; AT91C_BASE_PIOA->PIO_IER = mask; AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOA; AT91C_BASE_PIOA->PIO_ISR; AT91C_BASE_PIOA->PIO_IDR = 0xFFFFFFFF; // without the mask AT91F_AIC_ConfigureIt( AT91C_BASE_PIOA, (unsigned int)29, 0x0, 0x0, ISR_Bp1); AT91F_AIC_EnableIt( AT91C_BASE_PIOA, (unsigned int)29 ); [/code]
And my interrupt handler will make the onboard LED flash: [code] if( AT91F_PIO_GetInput( AT91C_BASE_PIOA ) & LED1 ) { AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED1); } else { AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED1 ); } [/code]
Handling the interrupt shouldn't be such a hard thing to do... I'm sure that I've got wrong some of the configurations but I have know idea how is the right way to cinfigure the interrupt using the FreeRTOS sam7x port.
Thanks
How is the right syntax for the [Code] tag?
|