tonkostz
Joined: 07 May 2011 Posts: 40 Location: Bulgaria
|
Strange behavior of the CCS USB bootloader |
Posted: Sat Apr 19, 2014 5:11 am |
|
|
I am using the ccs usb bootloader (without changes) to upload my application but here is what happens when i do it:
I have a led connected to pin C7 which never lights when uploading the program through the bootloader. If i upload it by using a programmer (PICkit 3 in my case) everything is ok and the led lights up.
The only thing i changed i the ccs usb bootloader is the fuses. Here are my defines and fuses:
Code: | #include <18F4550.h>
#device HIGH_INTS=TRUE
#device adc=10
#fuses HSPLL, PLL5, CPUDIV1, NOWDT, MCLR, PUT, NOLVP, USBDIV, VREGEN, BORV43, BROWNOUT, PROTECT, CPB, CPD
#use delay(clock=48000000) |
In my application i added absolutely the same fuses.
There is another problem too. I am generating a software PWM with 16.6Hz frequency and 800uS pulse width. When uploading the program with the programmer everything is ok but if i upload it through the bootloader pulse width is not 800uS - it is around 850uS. Here is the program:
My compiler version is 4.120.
Code: | #include <18F4550.h>
#device HIGH_INTS=TRUE
#device adc=10
#fuses HSPLL,PLL5,CPUDIV1,NOWDT,MCLR,PUT,NOLVP,USBDIV,VREGEN,BORV43,BROWNOUT,PROTECT,CPB,CPD
#use delay(clock=48000000)
#include <usb_bootloader.h>
#define PWM_OUT PIN_E2
#define TIMER0_PRELOAD 149
#define LOOPCNT 4925 //f=16.6Hz and T=60mS
int8 width=55;
#INT_RTCC HIGH //high priority interrupt
void tick_interrupt(void)
{
static int16 loop = LOOPCNT;
static int16 pulse;
set_timer0(get_timer0() + TIMER0_PRELOAD);
if(--loop==0)
{
loop=LOOPCNT;
pulse=width;
}
if(pulse)
{
output_high(PWM_OUT);
pulse--;
}
else output_low(PWM_OUT);
}
void main()
{
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_1 | RTCC_8_BIT);
set_timer0(TIMER0_PRELOAD);
enable_interrupts(INT_RTCC);
} |
|
|