View previous topic :: View next topic |
Author |
Message |
bernardinim
Joined: 07 Dec 2005 Posts: 10 Location: Italy
|
RTOS and PIC18F2525 |
Posted: Tue Dec 13, 2005 7:47 am |
|
|
Why the example code of ccs about rtos (for pic18f452) not work on pic18f2525. What's are the differences? |
|
|
bernardinim
Joined: 07 Dec 2005 Posts: 10 Location: Italy
|
|
Posted: Wed Dec 14, 2005 2:34 am |
|
|
my rtos code not work.....
what is wrong in my code??
(I use a 32Mhz external clock)
#include <18F2525.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES EC //External clock
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOFCMEN //Fail-safe clock monitor enabled
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES NOLPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#use delay(clock=32000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use rtos(timer=0,minor_cycle=100ms)
#task(rate=1000ms,max=100ms)
void The_first_rtos_task()
{
output_high(PIN_C0);
delay_ms(50);
output_low(PIN_C0);
}
#task(rate=500ms,max=100ms)
void The_second_rtos_task()
{
output_high(PIN_C0);
delay_ms(50);
output_low(PIN_C0);
}
void main()
{
int i;
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL|0x40);
setup_timer_1(T1_INTERNAL);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_low_volt_detect(FALSE);
setup_oscillator(False);
setup_oscillator(OSC_NORMAL);
printf("start\n\r");
set_timer0(0);
delay_ms(1000);
i=get_timer0();
printf("%d",i);
set_timer0(0);
delay_ms(1000);
i=get_timer0();
printf("%d",i);
rtos_run();
}
Can someone help me??? |
|
|
Guest
|
|
Posted: Wed Dec 14, 2005 7:46 pm |
|
|
does not work means ??
Your question is not complete..... |
|
|
bernardinim
Joined: 07 Dec 2005 Posts: 10 Location: Italy
|
RTOS |
Posted: Thu Dec 15, 2005 2:34 am |
|
|
The task not start... I tried different fuse configurations without success...
The strange thing is that the code work on PIC18F452 and not on PIC18F2525... I not know why... I think that rtos needs only a timer for schedule task... |
|
|
cstan_02
Joined: 24 Jul 2005 Posts: 13
|
|
Posted: Thu Dec 15, 2005 7:43 pm |
|
|
Code: |
set_timer0(0);
delay_ms(1000);
i=get_timer0();
printf("%d",i);
set_timer0(0);
delay_ms(1000);
i=get_timer0();
printf("%d",i);
rtos_run(); |
Have you tried assigning a different timer for RTOS, say timer 1 ??
I'm afraid that you may be using the timer0 that is being assigned to the RTOS.
Code: | #use rtos(timer=0,minor_cycle=100ms) |
|
|
|
|