Re: IAR AVR Port
Posted: Fri Dec 07, 2012 1:45 pm
Not sure, you should verify the preprocessed output, is there an option to see it?
Giovanni
Giovanni
Code: Select all
#define TIMER0_COMP_vect (0x28)Code: Select all
#define TIMER0_COMP_vector 0x28 handaza wrote:also I like to contribute my work bake, how can I send these files? and should I send what I finished now or wait till I finish the HAL?
Code: Select all
MAIN: > *** ROBOT-X V.1.00 14/03/2013***
MAIN: > CPU is AVR atXMega128A1, XTAL = 32MHz
MAIN: > Compiled Mar 14 2013 21:55:51
MAIN: > ChibiOS Version: 2.5.2
*** ChibiOS/RT test suite
***
*** Kernel: 2.5.2unstable
*** Compiled: Mar 14 2013 - 21:56:13
*** Compiler: IAR C/C++ Compiler V6.11.1.50453 for Atmel AVR
*** Architecture: AVR
*** Core Variant: xMegaAVR
*** Port Info: IAR XMEGA by ALEX BLACK
*** Platform: XMEGA
*** Test Board: PHOTOROBOT-X
----------------------------------------------------------------------------
--- Test Case 1.1 (Threads, enqueuing test #1)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.2 (Threads, enqueuing test #2)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.3 (Threads, priority change)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.4 (Threads, delays)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.1 (Semaphores, enqueuing)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.2 (Semaphores, timeout)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.3 (Semaphores, atomic signal-wait)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.4 (Binary Semaphores, functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.1 (Mutexes, priority enqueuing test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.2 (Mutexes, priority return)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.3 (Mutexes, status)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.4 (CondVar, signal test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.5 (CondVar, broadcast test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.6 (CondVar, boost test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 4.1 (Messages, loop)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 5.1 (Mailboxes, queuing and timeouts)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.1 (Events, registration and dispatch)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.2 (Events, wait and broadcast)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.3 (Events, timeouts)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 10.1 (Queues, input queues)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 10.2 (Queues, output queues)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
Code: Select all
Scratch registers
Any function is permitted to destroy the contents of a scratch register. If a function needs the register value after a call to another function, it must store it during the call, for example on the stack. For both calling conventions, these 14 registers can be used as scratch registers by a function:
R0-R3, R16-R23, and R30-R31
Code: Select all
Preserved registers
Preserved registers, on the other hand, are preserved across function calls. The called function can use the register for other purposes, but must save the value before using the register and restore it at the exit of the function. For both calling conventions, these registers are preserved registers:
R4-R15 and R24-R27
Code: Select all
Special registers
For some registers, you must consider certain prerequisites:
◠The stack pointer—register Y—must at all times point to the last element on the stack. In the eventuality of an interrupt, everything below the point the stack pointer points to, will be destroyed.
â— If using the -v4 or -v6 processor option, the RAMPY register is part of the data stack pointer.
â— If using a processor option which uses any of the registers EIND, RAMPX, or RAMPZ, these registers are treated as scratch registers.
Code: Select all
Register parameters
For both calling conventions, the registers available for passing parameters are:
R16–R23
Code: Select all
Interrupt functions
Interrupt functions differ from ordinary C functions in that:
â— Calls to interrupt functions are made via interrupt vectors; direct calls are not allowed
â— No arguments can be passed to an interrupt function
â— Interrupt functions return by using the RETI function.
Code: Select all
volatile static uint32_t kkkk = 0;
static WORKING_AREA(waThread1, 32);
static msg_t Thread1(void *arg)
{
(void) arg;
while (TRUE)
{
chSysLock();
kkkk++;
chSysUnlock();
}
}
Code: Select all
int main( void )
{
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
// Init debug serial interface
DEBUG_INIT();
/* Starts the Thread1 */
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
uint32_t i = 0;
for (;;)
{
i++;
chSysLock();
uint32_t vk = kkkk;
chSysUnlock();
chprintf(dbg_port, "\ri = %lu, k = %lu ", i, vk);
}
}
Giovanni wrote:There is an important symptom, it crashes if you preempt a running thread, this means that the problem is in the preemption code. Probably you fail to save all the required registers in the ISRs (the extctx structure). It is very possible the problem is there also because the IAR is a different compiler and does not necessarily do things like GCC does.
Giovanni
Giovanni wrote:Few things to check:
- ISR functions declaration.
- extctx structure.
- Registers saved in ISRs by the compiler.
Giovanni