View previous topic :: View next topic |
Author |
Message |
adcor
Joined: 21 Feb 2008 Posts: 31
|
PCD bootloader and PWM issues [solved] |
Posted: Mon Jun 18, 2018 9:48 pm |
|
|
Actually this is a follow up of a PWM issue I had yesterday and Ttelmah helped me to sort it out for a CCS 5.077 and PIC24FJ128GC006 platform. Burning this hex directly to the chip I have no issues with PWM and LED toggling.
Code: |
#include <24FJ128GC006.h>
#DEVICE CONST=READ_ONLY
#device ADC=12
//#include <pcd_bootloader.h>
#FUSES FRC_PLL, PLL2, NOPROTECT, NOWDT, NOWRT, NODEBUG
#USE delay(internal=8MHZ, clock=32MHz)
#pin_select OC1 = PIN_B4 // PWM out 4khz
void set_test_pwm (void) { // 4kHz for 50% DC
setup_compare(1,COMPARE_PWM_EDGE | COMPARE_SYSTEM_CLOCK | COMPARE_TRIG_SYNC_SELF);
set_pwm_period(1,4000);
set_pwm_duty(1,2000);
}
void main()
{
set_test_pwm();
while (1) {
output_toggle(pin_G9); // toggle LED
delay_ms(500);
}
} |
Now, having the pcd bootloader loaded for this chip and compiling <pcd_bootloader.h> in the above, LED will still toggle but PWM disappeared.
The bootloader works for my project (2k+ lines), so this is when I stumbled adding the PWM to it and not have it working and forcing me to simplify and find the cause. Any suggestions much appreciated,
thanks |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Tue Jun 19, 2018 5:07 am |
|
|
while I don't use that PIC, perhaps increasing the Stack size will help. That seems to be one answer common to 'it worked yesterday but now....' problems.
At least it's easy to do/test/confirm/deny....
Jay |
|
|
adcor
Joined: 21 Feb 2008 Posts: 31
|
|
Posted: Tue Jun 19, 2018 5:34 am |
|
|
I tried it up to 1024 but no luck.
thanks |
|
|
adcor
Joined: 21 Feb 2008 Posts: 31
|
|
Posted: Tue Jun 19, 2018 10:22 pm |
|
|
Just to confirm that PWM does not work for both serial RS232 and USB bootloader. Are somehow the PWM related functions overlapping with the bootloader?!
thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Wed Jun 20, 2018 2:24 am |
|
|
First obvious thing is fuses.
Remember your fuses in your code _do nothing_ when you are using a bootloader. You are running with the fuses the bootloader sets.
I personally prefer to have my main code using #FUSES NONE, and put a remark block like:
Code: |
#fuses NONE
/* FUSES in bootloader:
FUSES xxxxxx //whatever they are...
*/
|
Now if (for instance) the IOL1WAY fuse is set in the bootloader (check the .lst file since it may be set by default), then the #PIN SELECT in your run time code won't be able to program the pin, since it will have been locked by the bootloader code.... |
|
|
adcor
Joined: 21 Feb 2008 Posts: 31
|
SOLVED:PCD bootloader and PWM issues |
Posted: Wed Jun 20, 2018 2:52 pm |
|
|
Thank you Ttelmah, it was IOL1WAY fuse set by default in the bootloader. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Jun 21, 2018 12:28 am |
|
|
Hurrah!.... |
|
|
|