SAM7X256 on Olimex board not running

Greetings, I have tried now for a very long time to get the board showing some kind of life but with no luck so far. Help is needed… The program I try to make running is just one simple task where I want to blink the display backlight: void vBlinkTask ( void *pvParameters ) {     (void) pvParameters;         AT91C_BASE_PIOB->PIO_PER = AT91C_PIO_PB20; // Set in PIO mode     AT91C_BASE_PIOB->PIO_OER = AT91C_PIO_PB20; // Configure in Output     while (1)     {       AT91C_BASE_PIOB->PIO_SODR = AT91C_PIO_PB20;       vTaskDelay(1000 / portTICK_RATE_MS);       AT91C_BASE_PIOB->PIO_CODR = AT91C_PIO_PB20;       vTaskDelay(1000 / portTICK_RATE_MS);     } } In the main loop I try to start the task by : xTaskCreate( vBlinkTask, ( signed portCHAR * ) "Blink", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL ); before I call vTaskStartScheduler(); The backlight lights up all right but it stays on. I seems to me that the scheduler is not running. In Port.c I initialize the tick interrupt this way:     /* Configure the PIT period. */     AT91F_PITInit (AT91C_BASE_PITC, 1000, 48);     AT91F_PITEnableInt (AT91C_BASE_PITC);     AT91F_PITC_CfgPMC();     AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SYS); Is there anyone out there who can point out for me where to look in order to make the OS running ? If more info is needed please let me know. Best Regards RaceMouse

SAM7X256 on Olimex board not running

Try without the OS to start with to check out the rest of the code in the simplest way.  For example, your program could: int main( void ) { ____prvSetupHardwarePorts(); ____prvSetupTimer(); ____enable_interrupts(); ____while( 1 ); } Then in the timer: void TimerISR( void ) { ____static int i = 0; ____++i; ____if( i == 1000 ) ____{ ________// Toggle back light here. ________i = 0;     } } Once this is working you can convert to use the RTOS.  Just have a NULL task that does nothing, and convert the TimerISR() code above to the tick hook function to check that the timer is still running correctly when the RTOS is up and going. Finally once that is done, then you can remove the tick hook and go back to your original code. Just my thought.

SAM7X256 on Olimex board not running

Hi again, First : Thanks for taking your time to help me out. Getting a simple interrupt routine working first is a good idea. I have been sitting with it for a while and interrupts are still not firing. I have just one file now – main.c: #include <AT91SAM7X256.h> #include <lib_AT91SAM7X256.h> void prvSetupHardwarePorts(void); void prvSetupTimer(void); void enable_interrupts(void); void vISR (void) __attribute__ ((interrupt ("IRQ")));; void prvSetupHardwarePorts(void) { __AT91F_PIO_CfgPeriph (AT91C_BASE_PIOB, AT91C_PIO_PA20, AT91C_PIO_PB20); __AT91F_PIO_CfgOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20); } void prvSetupTimer(void) { __/* Configure the PIT period. */ __AT91F_PITInit (AT91C_BASE_PITC, 1000, 48); __AT91F_PITEnableInt (AT91C_BASE_PITC); __AT91F_PITC_CfgPMC(); } void enable_interrupts(void) { __AT91F_AIC_ConfigureIt( AT91C_BASE_AIC, AT91C_ID_SYS, AT91C_AIC_PRIOR_HIGHEST, 0, ( void (*)(void) ) vISR ); __AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SYS); } void vISR ( void ) { __static int i = 0; __++i; __if( i >= 1000 ) __{ ____// Toggle back light here. ____if (AT91F_PIO_GetInput (AT91C_BASE_PIOB) & AT91C_PIO_PB20) ______AT91F_PIO_SetOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20); ____else ______AT91F_PIO_ClearOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20); ____i = 0; __} } int main( void ) { __prvSetupHardwarePorts(); __prvSetupTimer(); __enable_interrupts(); __while( 1 ); } The other files Cstartup_SAM7.c and boot.s are taken from the "lwIP_Demo_Rowley_ARM7" project. In boot.s I have uncommented the references to swi_handler in order to be able to compile. Otherwise they are both unchanged. Everything is compiled in ARM-mode. Any suggestions ? /RaceMouse

SAM7X256 on Olimex board not running

Come to think of it there must be something else wrong : Should this not make the back light blink at some rate ? int main( void ) { __static int i = 0;   __while( 1 ) __{ ____++i; ____if( i >= 10000 ) ____{ ______// Toggle back light here. ______if (AT91F_PIO_GetInput (AT91C_BASE_PIOB) & AT91C_PIO_PB20) ________AT91F_PIO_ClearOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20); ______else ________AT91F_PIO_SetOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20); ______i = 0; ____} __} } /RaceMouse

SAM7X256 on Olimex board not running

Is it possible that the PIT interrupt is executing once but then not being cleared?  At the end of the ISR you probably need something like:         /* Clear the PIT interrupt. */         ulDummy = AT91C_BASE_PITC->PITC_PIVR;                 /* End the interrupt in the AIC. */         AT91C_BASE_AIC->AIC_EOICR = ulDummy; Also, do you have global interrupts enabled? portENABLE_INTERRUPTS().

SAM7X256 on Olimex board not running

Hi again, Still no luck. Followed your suggestions and I’ve taken the portENABLE_INTERRUPTS () from portmacro.h from the SAM7S directory. Now my main looks like this but still no go :-( #include <AT91SAM7X256.h> #include <lib_AT91SAM7X256.h> #define portENABLE_INTERRUPTS()                                      asm volatile (                                                       "STMDB  SP!, {R0}   nt"    /* Push R0.                   */      "MRS  R0, CPSR      nt"    /* Get CPSR.                  */      "BIC  R0, R0, #0xC0 nt"    /* Enable IRQ, FIQ.           */      "MSR  CPSR, R0      nt"    /* Write back modified value. */      "LDMIA  SP!, {R0}       " )  /* Pop R0.                    */ void vISR (void) __attribute__ ((interrupt ("SWI"))); void vISR (void) {   unsigned long ulDummy;     // Toggle back light here.   if (AT91F_PIO_GetInput (AT91C_BASE_PIOB) & AT91C_PIO_PB20)     AT91F_PIO_ClearOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20);   else     AT91F_PIO_SetOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20);       ulDummy = AT91C_BASE_PITC->PITC_PIVR;   AT91C_BASE_AIC->AIC_EOICR = ulDummy;   } int main( void ) {   // Setup hardware   AT91F_PIO_CfgPeriph (AT91C_BASE_PIOB, AT91C_PIO_PA20, AT91C_PIO_PB20);   AT91F_PIO_CfgOutput (AT91C_BASE_PIOB, AT91C_PIO_PB20);     // Setup PIT   AT91F_PITInit (AT91C_BASE_PITC, 1000, 48);   AT91F_PITEnableInt (AT91C_BASE_PITC);   AT91F_PITC_CfgPMC();       // Enable interrupts   AT91F_AIC_ConfigureIt( AT91C_BASE_AIC, AT91C_ID_SYS, AT91C_AIC_PRIOR_HIGHEST, 0, ( void (*)(void) ) vISR );   AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SYS);     portENABLE_INTERRUPTS ();     while( 1 ); } My hair is getting thin :-( /RaceMouse

SAM7X256 on Olimex board not running

Running out of ideas here!  This seems unreleated to FreeRTOS, just trying to get the damned interrupt to work. On the SAM7 I think the PIT uses the system interrupt, which is shared amongst a few other peripherals (WDG for example).  Could it be that something else has already grabbed the interrupt vector? Is you setup code copied from the FreeRTOS port? Clutching at straws – Are any other interrupts working? Does your code to turn the back light on and off work without interrupts? Are you able to set a break point on the AIC address? Does your startup code allow you to define your own verctors?  The Atmel standard code will define a routine for each peripheral I think, the behavior of which is to just return and do nothing.  Could it be that this code is executing in place of yours?

SAM7X256 on Olimex board not running

In boot.s the "swi_handler" was commented out. Could that be it ? If I uncomment it the linker complains about en undefined reference to the swi_handler. should the swi_handler just be an empty function in this case ? boot.s and Cstartup_SAM7.c are taken from the FreeRTOS package…. /RaceMouse

SAM7X256 on Olimex board not running

Where did you comment it out? from boot.s – b     _start            /* reset – _start            */ ldr   pc, _undf            /* undefined – _undf        */ (*)ldr   pc, _swi            /* SWI – _swi                */ ldr   pc, _pabt            /* program abort – _pabt    */ ldr   pc, _dabt            /* data abort – _dabt        */ nop                /* reserved                    */ ldr   pc, [pc,#-0xF20]        /* IRQ – read the AIC        */ ldr   pc, _fiq            /* FIQ – _fiq                */ _undf:  .word __undf            /* undefined                */ (**)_swi:   .word swi_handler    /* SWI                        */ _pabt:  .word __pabt            /* program abort            */ _dabt:  .word __dabt            /* data abort                */ _fiq:   .word __fiq             /* FIQ                        */ If you comment out line (*) then this will definately cause a big problem as your IRQ interrupt will end up on the wrong vector. If you comment out (**) then you will not do any harm but will get a link error. You can define a – void swi_handler( void ) {} just to get it to link.  This will be ok for your small demo program as SWI is not called.  It will not be ok for the FreeRTOS program though.

SAM7X256 on Olimex board not running

Hmmm… Now I tried (as yet another desperate attempt) to take the "vanilla" source from sf.net, unpacked it, in "lwIP_Demo_Rowley_ARM7" modified partest.c to toggle PortB.20. It compiled and linked without any trouble. I uploaded it to the uC but the result was still the same. Can it be the board that makes this so difficult to make it work ? Am I the only one with a SAM7X256-board from Olimex ? I’m out of ideas :-( /RaceMouse

SAM7X256 on Olimex board not running

The solution has been found : I should not use the lib_AT91SAM7X256 header. It is apparently i bit buggy ?!?! When I do not use the inline functions but write/read to/from the SFR’s it works…. /RaceMouse