Hi Martin.
Here's a very quick solution: change
code:
#define OS_Yield(label) do { OSCtxSw(); } while (0)
in salvoincportgccavr.h to
code:
#define OS_Yield(label) do { OSCtxSw(); asm volatile(" nop"::); } while (0)
Instead of
code:
+00000029: 93CF PUSH R28 Push register on stack
+0000002A: 93DF PUSH R29 Push register on stack
35: counter++;
+0000002B: 91800062 LDS R24,0x0062 Load direct from data space
+0000002D: 91900063 LDS R25,0x0063 Load direct from data space
+0000002F: 9601 ADIW R24,0x01 Add immediate to word
+00000030: 93900063 STS 0x0063,R25 Store direct to data space
+00000032: 93800062 STS 0x0062,R24 Store direct to data space
37: if ((counter %2) == 0)
+00000034: 2FD9 MOV R29,R25 Copy register
+00000035: 2FC8 MOV R28,R24 Copy register
+00000036: 70C1 ANDI R28,0x01 Logical AND with immediate
+00000037: 70D0 ANDI R29,0x00 Logical AND with immediate
+00000038: FD80 SBRC R24,0 Skip if bit in register cleared
+00000039: CFF1 RJMP -0x000F Relative jump
39: OS_Yield(TaskCount1);
+0000003A: D1B6 RCALL +0x01B6 Relative call subroutine
40: its_wrong = 0;
+0000003B: 93D00061 STS 0x0061,R29 Store direct to data space
+0000003D: 93C00060 STS 0x0060,R28 Store direct to data space
34: for (;;) {
+0000003F: CFEB RJMP -0x0015 Relative jump
you'll get
code:
35: counter++;
+00000029: 91800062 LDS R24,0x0062 Load direct from data space
+0000002B: 91900063 LDS R25,0x0063 Load direct from data space
+0000002D: 9601 ADIW R24,0x01 Add immediate to word
+0000002E: 93900063 STS 0x0063,R25 Store direct to data space
+00000030: 93800062 STS 0x0062,R24 Store direct to data space
37: if ((counter %2) == 0)
+00000032: FD80 SBRC R24,0 Skip if bit in register cleared
+00000033: CFF5 RJMP -0x000B Relative jump
39: OS_Yield(TaskCount1);
+00000034: D1B8 RCALL +0x01B8 Relative call subroutine
+00000035: 0000 NOP No operation
40: its_wrong = 0;
+00000036: 92100061 STS 0x0061,R1 Store direct to data space
+00000038: 92100060 STS 0x0060,R1 Store direct to data space
34: for (;;) {
+0000003A: CFEE RJMP -0x0012 Relative jump
which is smaller and correct, but may be slower.
Sorry about the inconvenience -- there may be an opportunity to further optimize the context switcher, and I'm looking at it right now ...
------------------
[This message has been edited by aek (edited December 19, 2003).]