|
|
View previous topic :: View next topic |
Author |
Message |
babos
Joined: 06 Jun 2010 Posts: 10 Location: Italy
|
PCD: Trouble with RTOS |
Posted: Sun Jun 06, 2010 11:15 am |
|
|
I'm new from CCS compiler and from SourceBoost C++(rtos).
Now I 've make some test like this :
Code: |
#include <33FJ256GP710.h>
#DEVICE ADC=10
#fuses HS,PR_PLL // Crystal HS, 4xPLL
#fuses NOIESO // No 2-speed Start Up
#fuses NOJTAG // No JTAG
#fuses NOPROTECT // No Memory Protection
#fuses NOWDT // No WatchDog Timer
#fuses NODEBUG // Debug Mode.
#use delay(clock=40M, oscillator=8M)
#use rs232(UART2, STREAM=serial_debug, baud=9600, bits=8)
#include "lcd_ex16.c"
#include "init_timer1.c"
#include "isr_rtc.c"
#include "init_ADC.c"
unsigned char seconds = 0; #locate seconds = 0x900
unsigned char minutes = 0; #locate minutes = 0x902
unsigned char hours = 0; #locate hours = 0x904
unsigned int adc_value = 0; #locate adc_value = 0x906
int1 toggle_led = 0;
#int_timer1 level=4
void isr(void)
{
// RTC interrupt handler
toggle_led ^= 0x01;
if(toggle_led)
output_high(PIN_A0);
else
output_low(PIN_A0);
isr_rtc(); // refresh LCD RTC time
set_timer1(0x8000);
}
//==========================
void main()
{
// main program
//
Init_Timer1();
init_ADC();
lcd_init();
home_clr();
printf(lcd_puts,"\fRTC 00:00.00");
printf(lcd_puts,"\nADC 0.00 ");
delay_ms(1000);
output_float(PIN_A0);
//loop
while(1)
{
adc_value = read_adc();
lcd_gotoxy(5,2);
printf(lcd_puts,"%3.2f v.",adc_volts(adc_value));
delay_ms(100);
}
}
|
Omit any other files , this work fine without problem.
If i try to use rtos in this mode :
Code: |
#include <33FJ256GP710.h>
#DEVICE ADC=10
#fuses HS,PR_PLL // Crystal HS, 4xPLL
#fuses NOIESO // No 2-speed Start Up
#fuses NOJTAG // No JTAG
#fuses NOPROTECT // No Memory Protection
#fuses NOWDT // No WatchDog Timer
#fuses NODEBUG // Debug Mode.
#use delay(clock=32M, oscillator=8M)
#use rs232(UART2, STREAM=serial_debug, baud=9600, bits=8)
#use rtos(timer=0,minor_cycle=100ms)
#include "lcd_ex16.c"
#include "init_timer1.c"
#include "isr_rtc.c"
#include "init_ADC.c"
unsigned char seconds = 0; #locate seconds = 0x900
unsigned char minutes = 0; #locate minutes = 0x902
unsigned char hours = 0; #locate hours = 0x904
unsigned int adc_value = 0; #locate adc_value = 0x906
int1 toggle_led = 0;
#task(rate=100ms,max=100ms)
void task1();
#int_timer1 level=4
void isr(void)
{
// RTC interrupt handler
toggle_led ^= 0x01;
if(toggle_led)
output_high(PIN_A0);
else
output_low(PIN_A0);
isr_rtc();
set_timer1(0x8000);
}
//==========================
void task1()
{
adc_value = read_adc();
lcd_gotoxy(5,2);
printf(lcd_puts,"%3.2f v.",adc_volts(adc_value));
}
void main()
{
// main program
//
Init_Timer1();
init_ADC();
lcd_init();
home_clr();
printf(lcd_puts,"\fRTC 00:00.00");
printf(lcd_puts,"\nADC 0.00 ");
delay_ms(1000);
output_float(PIN_A0);
rtos_run();
//loop
}
|
The debugger (I maybe) have a stack overflow or other and stop it resetting CPU.
What's wrong?
Thanks for your help.
Babos
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 06, 2010 1:25 pm |
|
|
What's your compiler version ? According to this thread, there were
problems with the RTOS in the PCD compiler, in mid-August 2009.
This would be around version 4.096 of the compiler.
http://www.ccsinfo.com/forum/viewtopic.php?t=39677
I don't have the PCD compiler, so I can't give any more help than this. |
|
|
babos
Joined: 06 Jun 2010 Posts: 10 Location: Italy
|
|
Posted: Sun Jun 06, 2010 1:28 pm |
|
|
CCS C Compiler version 4.1.0.8 PCD is the current that I use.
Best regards.
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Jun 06, 2010 2:05 pm |
|
|
You should check what's the exact reset cause. Stack overflow doesn't sound unlikely, because PCD has a (too) low default stack assignment. Stack overflows have been reported e.g. with float arithmetic. You may want to try with an increased stack size. |
|
|
babos
Joined: 06 Jun 2010 Posts: 10 Location: Italy
|
|
Posted: Sun Jun 06, 2010 3:30 pm |
|
|
Is the same with this sample code !!!!
Code: |
#include <33FJ256GP710.h>
#DEVICE ADC=10
#fuses HS,PR_PLL // Crystal HS, 4xPLL
#fuses NOIESO // No 2-speed Start Up
#fuses NOJTAG // No JTAG
#fuses NOPROTECT // No Memory Protection
#fuses NOWDT // No WatchDog Timer
#fuses NODEBUG // Debug Mode.
#use delay(clock=40M, oscillator=8M)
#use rs232(UART1, STREAM=serial_debug, baud=9600, bits=8)
#use rtos(timer=0, minor_cycle=100ms)
#task(rate=1000ms, max=100ms)
void first_task()
{
printf("task 1\n\r");
}
#task(rate=500ms,max=100ms)
void second_task()
{
printf("task 2\n\r");
}
#task(rate=100ms,max=100ms)
void third_task()
{
printf("task 3\n\r");
}
// MAIN
void main()
{
rtos_run();
}
|
there would have to put any switch (?) in a linker compiler setting before use RTOS????
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Jun 06, 2010 11:25 pm |
|
|
You can try, if increasing the stack changes anything
Code: | #build(stack = 256) |
But there may be other reset causes (e.g. address error trap) as well. Because all exceptions are unhandled by default, you won't see but a trap conflict in the reset register. You need to install respective trap interrupts to identify specific execptions. |
|
|
babos
Joined: 06 Jun 2010 Posts: 10 Location: Italy
|
|
Posted: Mon Jun 07, 2010 12:36 am |
|
|
Nothing to do. Please see me how trap interrupts in previous sample code.Thank's.
I use :
Explorer16 demo board with Mplab 8.50 + ICD2
this is the build result:
Code: |
Executing: "C:\Program files\Picc\CCSC.exe" +FD "rtos_1.c" +DF +LN +T +A +M -Z +ICD +Y=9 +EA Memory usage: ROM=1% RAM=1% - 1% 0 Errors, 0 Warnings.Loaded E:\nanoGel\firmware\rtos_1\rtos_1.cof.BUILD SUCCEEDED: Mon Jun 07 08:27:45 2010
|
This, the disassembly listing :
Code: |
--- C:\PROGRA~1\PICC\devices\33FJ256GP710.h ----------------------------------------------------
1: //////// Standard Header file for the DSPIC33FJ256GP710 device ////////////////
2: #device DSPIC33FJ256GP710
00200 EF2032 clr.w 0x0032
00202 2020C3 mov.w #0x20c,0x0006
00204 418000 add.w 0x0006,0x0000,0x0000
00206 BA4010 tblrdl.b [0x0000],0x0000
00208 EF6001 clr.b 0x0001
0020A 060000 return
0020C 006174 nop
0020E 006B73 nop
00210 003120 nop
00212 000D0A nop
00214 000000 nop
00216 EF2032 clr.w 0x0032
00218 202223 mov.w #0x222,0x0006
0021A 418000 add.w 0x0006,0x0000,0x0000
0021C BA4010 tblrdl.b [0x0000],0x0000
0021E EF6001 clr.b 0x0001
00220 060000 return
00222 006174 nop
00224 006B73 nop
00226 003220 nop
00228 000D0A nop
0022A 000000 nop
0022C EF2032 clr.w 0x0032
0022E 202383 mov.w #0x238,0x0006
00230 418000 add.w 0x0006,0x0000,0x0000
00232 BA4010 tblrdl.b [0x0000],0x0000
00234 EF6001 clr.b 0x0001
00236 060000 return
00238 006174 nop
0023A 006B73 nop
0023C 003320 nop
0023E 000D0A nop
00240 000000 nop
00242 EF2032 clr.w 0x0032
00244 2024E3 mov.w #0x24e,0x0006
00246 418000 add.w 0x0006,0x0000,0x0000
00248 BA4010 tblrdl.b [0x0000],0x0000
0024A EF6001 clr.b 0x0001
0024C 060000 return
0024E 00085C nop
00250 000864 nop
00252 00086C nop
--- E:\nanoGel\firmware\rtos_1\rtos_1.c --------------------------------------------------------
1: #include <33FJ256GP710.h>
00000 0402D2 goto 0x0002d2
2:
3: #DEVICE ADC=10
4: #fuses HS,PR_PLL // Crystal HS, 4xPLL
5: #fuses NOIESO // No 2-speed Start Up
6: #fuses NOJTAG // No JTAG
7: #fuses NOPROTECT // No Memory Protection
8: #fuses NOWDT // No WatchDog Timer
9: #fuses NODEBUG // Debug Mode.
10:
11:
12:
13: #use delay(clock=40M, oscillator=8M)
14:
15:
16: #use rs232(UART1, STREAM=serial_debug, baud=9600, bits=8)
17:
18: #build(stack=256)
19:
20: #use rtos(timer=0, minor_cycle=100ms)
21:
22:
23: #task(rate=1000ms, max=100ms)
24: void first_task()
25: {
26: printf("task 1\n\r");
00254 200001 mov.w #0x0,0x0002
00256 780001 mov.w 0x0002,0x0000
00258 020200 call 0x000200
0025C E80081 inc.w 0x0002,0x0002
0025E 781F81 mov.w 0x0002,[0x001e++]
00260 AF2223 btsc.b 0x0223,#1
00262 37FFFE bra 0x000260
00264 881120 mov.w 0x0000,0x0224
00266 7800CF mov.w [--0x001e],0x0002
00268 200070 mov.w #0x7,0x0000
0026A E60800 cpsgt.w 0x0002,0x0000
0026C 37FFF4 bra 0x000256
27: }
0026E 202540 mov.w #0x254,0x0000
00270 B7E861 mov.b 0x0000,0x0861
00272 000000 nop
00274 B7E862 mov.b 0x0000,0x0862
00276 200000 mov.w #0x0,0x0000
00278 B7E863 mov.b 0x0000,0x0863
0027A 04039A goto 0x00039a
28:
29: #task(rate=500ms,max=100ms)
30: void second_task()
31: {
32: printf("task 2\n\r");
0027E 200001 mov.w #0x0,0x0002
00280 780001 mov.w 0x0002,0x0000
00282 020216 call 0x000216
00286 E80081 inc.w 0x0002,0x0002
00288 781F81 mov.w 0x0002,[0x001e++]
0028A AF2223 btsc.b 0x0223,#1
0028C 37FFFE bra 0x00028a
0028E 881120 mov.w 0x0000,0x0224
00290 7800CF mov.w [--0x001e],0x0002
00292 200070 mov.w #0x7,0x0000
00294 E60800 cpsgt.w 0x0002,0x0000
00296 37FFF4 bra 0x000280
33: }
00298 2027E0 mov.w #0x27e,0x0000
0029A B7E869 mov.b 0x0000,0x0869
0029C 000000 nop
0029E B7E86A mov.b 0x0000,0x086a
002A0 200000 mov.w #0x0,0x0000
002A2 B7E86B mov.b 0x0000,0x086b
002A4 04039A goto 0x00039a
34:
35: #task(rate=100ms,max=100ms)
36: void third_task()
37: {
38: printf("task 3\n\r");
002A8 200001 mov.w #0x0,0x0002
002AA 780001 mov.w 0x0002,0x0000
002AC 02022C call 0x00022c
002B0 E80081 inc.w 0x0002,0x0002
002B2 781F81 mov.w 0x0002,[0x001e++]
002B4 AF2223 btsc.b 0x0223,#1
002B6 37FFFE bra 0x0002b4
002B8 881120 mov.w 0x0000,0x0224
002BA 7800CF mov.w [--0x001e],0x0002
002BC 200070 mov.w #0x7,0x0000
002BE E60800 cpsgt.w 0x0002,0x0000
002C0 37FFF4 bra 0x0002aa
39: }
002C2 202A80 mov.w #0x2a8,0x0000
002C4 B7E871 mov.b 0x0000,0x0871
002C6 000000 nop
002C8 B7E872 mov.b 0x0000,0x0872
002CA 200000 mov.w #0x0,0x0000
002CC B7E873 mov.b 0x0000,0x0873
002CE 04039A goto 0x00039a
40:
41: // MAIN
42: void main()
43: {
002D2 A8E081 bset.b 0x0081,#7
002D4 EF2744 clr.w 0x0744
002D6 200124 mov.w #0x12,0x0008
002D8 883A34 mov.w 0x0008,0x0746
002DA 280004 mov.w #0x8000,0x0008
002DC 881104 mov.w 0x0008,0x0220
002DE 204004 mov.w #0x400,0x0008
002E0 881114 mov.w 0x0008,0x0222
002E2 200814 mov.w #0x81,0x0008
002E4 881144 mov.w 0x0008,0x0228
002E6 EFA32C setm.w 0x032c
002E8 EFA32A setm.w 0x032a
002EA EFA36C setm.w 0x036c
002EC EFA36A setm.w 0x036a
002EE 27700F mov.w #0x7700,0x001e
002F0 277FF0 mov.w #0x77ff,0x0000
002F2 B7A020 mov.w 0x0000,0x0020
002F4 000000 nop
44: rtos_run();
002F6 EF685C clr.b 0x085c
002F8 2000A4 mov.w #0xa,0x0008
002FA 8842E4 mov.w 0x0008,0x085c
002FC 200014 mov.w #0x1,0x0008
002FE 8842F4 mov.w 0x0008,0x085e
00300 202540 mov.w #0x254,0x0000
00302 B7E861 mov.b 0x0000,0x0861
00304 000000 nop
00306 B7E862 mov.b 0x0000,0x0862
00308 200000 mov.w #0x0,0x0000
0030A B7E863 mov.b 0x0000,0x0863
0030C EF6864 clr.b 0x0864
0030E 200054 mov.w #0x5,0x0008
00310 884324 mov.w 0x0008,0x0864
00312 EF2867 clr.w 0x0867
00314 2027E0 mov.w #0x27e,0x0000
00316 B7E869 mov.b 0x0000,0x0869
00318 000000 nop
0031A B7E86A mov.b 0x0000,0x086a
0031C 200000 mov.w #0x0,0x0000
0031E B7E86B mov.b 0x0000,0x086b
00320 EF686C clr.b 0x086c
00322 200014 mov.w #0x1,0x0008
00324 884364 mov.w 0x0008,0x086c
00326 EF286F clr.w 0x086f
00328 202A80 mov.w #0x2a8,0x0000
0032A B7E871 mov.b 0x0000,0x0871
0032C 000000 nop
0032E B7E872 mov.b 0x0000,0x0872
00330 200000 mov.w #0x0,0x0000
00332 B7E873 mov.b 0x0000,0x0873
00334 EF685A clr.b 0x085a
00336 EF2000 clr.w 0x0000
00338 2FFFF0 mov.w #0xffff,0x0000
0033A 2A0100 mov.w #0xa010,0x0000
0033C 217B80 mov.w #0x17b8,0x0000
0033E 218B80 mov.w #0x18b8,0x0000
00340 A90080 bclr.b 0x0080,#0
00342 8042D1 mov.w 0x085a,0x0002
00344 DD08C1 sl 0x0002,#1,0x0002
00346 020242 call 0x000242
0034A 784100 mov.b 0x0000,0x0004
0034C 40C0E1 add.b 0x0002,#1,0x0002
0034E 784001 mov.b 0x0002,0x0000
00350 B7E000 mov.b 0x0000,0x0000
00352 020242 call 0x000242
00356 B7E001 mov.b 0x0000,0x0001
00358 780302 mov.w 0x0004,0x000c
0035A 784116 mov.b [0x000c],0x0004
0035C 7840D6 mov.b [++0x000c],0x0002
0035E 784056 mov.b [++0x000c],0x0000
00360 B7E003 mov.b 0x0000,0x0003
00362 E80306 inc.w 0x000c,0x000c
00364 E80B16 inc.w [0x000c],[0x000c]
00366 784016 mov.b [0x000c],0x0000
00368 B7E001 mov.b 0x0000,0x0001
0036A AE2042 btss.b 0x0042,#1
0036C 370003 bra 0x000374
0036E E80306 inc.w 0x000c,0x000c
00370 E80B16 inc.w [0x000c],[0x000c]
00372 E90306 dec.w 0x000c,0x000c
00374 E80306 inc.w 0x000c,0x000c
00376 784016 mov.b [0x000c],0x0000
00378 B54003 sub.b 0x0003,0x0000
0037A AE2042 btss.b 0x0042,#1
0037C 37000E bra 0x00039a
0037E 784001 mov.b 0x0002,0x0000
00380 B54001 sub.b 0x0001,0x0000
00382 AE2042 btss.b 0x0042,#1
00384 37000A bra 0x00039a
00386 E90306 dec.w 0x000c,0x000c
00388 E90306 dec.w 0x000c,0x000c
0038A EB1B00 clr.w [0x000c++]
0038C EB1B00 clr.w [0x000c++]
0038E AFE004 btsc.b 0x0004,#7
00390 370004 bra 0x00039a
00392 E80306 inc.w 0x000c,0x000c
00394 781FB6 mov.w [0x000c++],[0x001e++]
00396 781FB6 mov.w [0x000c++],[0x001e++]
00398 060000 return
0039A EC685A inc.b 0x085a
0039C B3C033 mov.b #0x3,0x0006
0039E B5485A sub.b 0x085a,0x0000
003A0 AE2042 btss.b 0x0042,#1
003A2 37FFCF bra 0x000342
003A4 EF685A clr.b 0x085a
003A6 AF0080 btsc.b 0x0080,#0
003A8 37FFC9 bra 0x00033c
003AA 37FFFD bra 0x0003a6
003AC EFE85A setm.b 0x085a
003AE 37FFFF bra 0x0003ae
|
The source code is in the compiler manual. I do not know what to do.
|
|
|
babos
Joined: 06 Jun 2010 Posts: 10 Location: Italy
|
|
Posted: Tue Jun 08, 2010 4:11 pm |
|
|
Dear CCS Official Support,
have you any solution for my problem?
Please is urgent to know any answer.
I've buy $600.00 PCWHD IDE Compiler + another Year subsciption for upgrade ($375).
What I must do ??????????
sorry for languages.
best regards
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Tue Jun 08, 2010 9:41 pm |
|
|
This is NOT CCS Support!!!! This just a USER Forum.
Please read the notes at the top right of this web page.
Send support questions to CCS using the email provided above... _________________ Google and Forum Search are some of your best tools!!!! |
|
|
babos
Joined: 06 Jun 2010 Posts: 10 Location: Italy
|
|
Posted: Wed Jun 09, 2010 1:13 am |
|
|
Sorry... but I'm very demoralized. CCS does not respond to my requests and on the internet I only found the same problem with other people but no solution .... I Try in every way.
Thanks again if anyone can help me. Would it be possible to use a different RTOS with CCS? And if so, what would be the best?
|
|
|
marius
Joined: 03 Mar 2008 Posts: 2 Location: Banned
|
|
Posted: Wed Jun 09, 2010 9:21 am |
|
|
Hi,
I have the same problem on a PIC24f.
When the program try to execute rtos_run(); there are reset.
The restart_cause() is 15 which means RESTART_TRAP_CONFLICT.
I wrote one month ago to ccs support they said :
We have some one running some tests now on the PIC24 RTOS to find out
if there are any outstanding issues. Check back next week.
And nothing . I use PCD 4.107 version. |
|
|
babos
Joined: 06 Jun 2010 Posts: 10 Location: Italy
|
|
Posted: Sat Jun 12, 2010 2:35 am |
|
|
We just have to wait ???
Do you know if it works RTOS 18F series processors?
If I let you know news. The same you do, thanks Marius.
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Jun 12, 2010 7:55 am |
|
|
Quote: | The restart_cause() is 15 which means RESTART_TRAP_CONFLICT. |
Yes, that can be expected in case of an unhandled address error or stack overflow. It would be important to know which one of both has occured. I previously suggested to increase the stack as a first measure. Did you try?
For further reading, refer to the below threads:
http://www.ccsinfo.com/forum/viewtopic.php?t=36479
http://www.ccsinfo.com/forum/viewtopic.php?t=40083
Address error trap can be caused by bad pointer operations in user code, but mostly indicates a PCD bug, according to my experience. There have been various cases with previous PCD releases, and I expect some trapdoors still to remain.
Last edited by FvM on Sat Jun 12, 2010 8:00 am; edited 1 time in total |
|
|
babos
Joined: 06 Jun 2010 Posts: 10 Location: Italy
|
|
Posted: Sat Jun 12, 2010 7:59 am |
|
|
Ok FvM,
waiting do some testing. |
|
|
marius
Joined: 03 Mar 2008 Posts: 2 Location: Banned
|
|
Posted: Mon Jun 14, 2010 2:04 am |
|
|
babos wrote: | We just have to wait ???
Do you know if it works RTOS 18F series processors?
If I let you know news. The same you do, thanks Marius.
|
Yes CCS RTOS works on PIC18f ( 18f4523 for my application )
It was very easy to use. It was my 1st application with CCS RTOS.
best regards
Marius |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|