CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PCD bootloader and PWM issues [solved]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
adcor



Joined: 21 Feb 2008
Posts: 31

View user's profile Send private message

PCD bootloader and PWM issues [solved]
PostPosted: Mon Jun 18, 2018 9:48 pm     Reply with quote

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: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jun 19, 2018 5:07 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 19, 2018 5:34 am     Reply with quote

I tried it up to 1024 but no luck.
thanks
adcor



Joined: 21 Feb 2008
Posts: 31

View user's profile Send private message

PostPosted: Tue Jun 19, 2018 10:22 pm     Reply with quote

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: 19195

View user's profile Send private message

PostPosted: Wed Jun 20, 2018 2:24 am     Reply with quote

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

View user's profile Send private message

SOLVED:PCD bootloader and PWM issues
PostPosted: Wed Jun 20, 2018 2:52 pm     Reply with quote

Thank you Ttelmah, it was IOL1WAY fuse set by default in the bootloader.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Thu Jun 21, 2018 12:28 am     Reply with quote

Smile

Hurrah!....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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