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

Boot loaded code runs at different speed

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



Joined: 30 Jun 2012
Posts: 45

View user's profile Send private message

Boot loaded code runs at different speed
PostPosted: Sat Jun 30, 2012 6:18 am     Reply with quote

I have written a boot loaders for PIC24 that use USB and RS232. Downloading and running code, interrupts, baud rates etc all work fine.

However the boot loaded code runs slower than when programmed in via MPLAB. I.E the LED is seen to toggle about 5 time slower.

I am guessing it is something to do with configuration.

Could anyone help with this ? The outline of the code is shown below.


Application downloaded by boot loader

#device PIC24FJ256GB108

#use delay(clock=20000000)
#FUSES WPOSTS9 //Watch Dog Timer PostScaler 1:256
#FUSES NOWDT //Development only
#FUSES NOWRT //Program memory not to be write protected
#FUSES NOJTAG //JTAG disabled
#FUSES HS //High speed osc (>4MHz for
#FUSES CKSFSM //Clock switching is enabled,
#FUSES PR //Primary Oscillator
#FUSES PLL5 //Divide by 5 (20MHz oscillator input)

#use rs232(UART2, baud=28800, PARITY=E,BITS =8, STOP=1, RESTART_WDT)


#ORG 0x200, 0x0F000
#FUSES ICSP3 // Rev 2 H/W

void main(void)
{
init();

for(;;)
{
toggle_led();

channel_RS232_comms()]

delay_ms(100);
}

}


--- Boot loader ------------------------------------------------
use delay(clock=20000000)
#FUSES WPOSTS9 //Watch Dog Timer PostScaler 1:256
#FUSES NOWDT
#FUSES NOWRT //Program memory not to be write protected
#FUSES NOJTAG //JTAG disabled
#FUSES HS //High speed osc (>4MHz for PCM/PCH)
#FUSES CKSFSM //Clock switching is enabled,
#FUSES PR //Primary Oscillator
#FUSES PLL5 //Divide by 5 (20MHz oscillator input)
#FUSES ICSP3

#use rs232(UART2, baud=28800, PARITY=E,BITS =8, STOP=1, RESTART_WDT)

#include "includes\24FJ256GB108.h"
#ORG 0x020000, 0x28000 default
#build(ALT_INTERRUPT)

void main(void)
{
init();

// Give User chance to upload new program
WHILE (TRUE)
{
count ++;

if ( (count > 2000) )
{
count = 0 ;

// Check for existing application.
if ( app_flag() )
{
goto_address ( 0x0200);
}
}

delay_ms (1);

// Usual boot code - load HEX file via RS232 then jumps to 0x200
check_for_incoming_data();
}
}

BTW if any ones a copy of the boot loader I can post it or email it.


Thanks

Bill24
temtronic



Joined: 01 Jul 2010
Posts: 9174
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jun 30, 2012 6:32 am     Reply with quote

comment..

hmmm....5 times slower ..... sounds like the fuse PLL5 may not be set.

I'd dump the listing files for each and check the fuses config to see if it's different.

Perhaps MPLAB is overriding the program config info...though I'd have thought it's be the same....

hth jay
Bill24



Joined: 30 Jun 2012
Posts: 45

View user's profile Send private message

PostPosted: Sat Jun 30, 2012 12:29 pm     Reply with quote

temtronic wrote:
comment..

hmmm....5 times slower ..... sounds like the fuse PLL5 may not be set.

I'd dump the listing files for each and check the fuses config to see if it's different.

Perhaps MPLAB is overriding the program config info...though I'd have thought it's be the same....

hth jay


Thanks Jay

Assuming PLL5 is set OK. Both the boot loader and application set it, and RS232 is ok and I believe the baud rate is derived from the clock.
Also the application runs at full speed when flashed directly.

Could it be that setting fuses twice could cause some kind of upset ?

TIA

Bill24
Bill24



Joined: 30 Jun 2012
Posts: 45

View user's profile Send private message

PostPosted: Sat Jun 30, 2012 12:34 pm     Reply with quote

Another thought. Could the speed change be due to

#FUSES ICSP3. E.g debug slowing things down ?
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