View previous topic :: View next topic |
Author |
Message |
Bill24
Joined: 30 Jun 2012 Posts: 45
|
Boot loaded code runs at different speed |
Posted: Sat Jun 30, 2012 6:18 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Sat Jun 30, 2012 6:32 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Bill24
Joined: 30 Jun 2012 Posts: 45
|
|
Posted: Sat Jun 30, 2012 12:29 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Bill24
Joined: 30 Jun 2012 Posts: 45
|
|
Posted: Sat Jun 30, 2012 12:34 pm |
|
|
Another thought. Could the speed change be due to
#FUSES ICSP3. E.g debug slowing things down ? |
|
![](templates/subSilver/images/spacer.gif) |
|