breeyet
Joined: 17 Dec 2006 Posts: 4
|
PIC24 #ORG |
Posted: Tue May 10, 2011 2:05 pm |
|
|
Hi,
I'm having trouble with the #ORG directive in the PCD rev 4.120 compiler. I need to locate a constant at 0xC00 and to have my main program start at 0x0C02. When I compile the code below, my interrupt routine is located at 0x0C02 and main is somewhere else.
I'm trying to use the 'mini-bully' bootloader to allow updating of my firmware and it requires that I place a constant at 0xC00 which represents the number of seconds to wait for a serial bootload attempt and that the code start location start at 0xC02.
Any guidance would be appreciated.
Code: |
#include <24FJ64GA002.h>
#device ADC=10
#use delay(clock=8000000) // 8 Mhz internal
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOJTAG //JTAG disabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES IOL1WAY //Allows only one reconfiguration of peripheral pins
#FUSES WINDIS //Watch Dog Timer in non-Window mode
#FUSES WPOSTS16 //Watch Dog Timer PostScalar 1:32768
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#build(stack = 512) // This line required or all %f printf formats will cause a stack overflow crash
#define PGM_END (getenv("PROGRAM_MEMORY")-1)
#define PGM_START 0x0C02
#org PGM_START, PGM_END default
int had_timer1_interrupt = 0;
void main(void)
{
int i;
setup_timer1(TMR_INTERNAL|TMR_DIV_BY_64); // 8Mhz/2/256 = 62500 tics per second
enable_interrupts(INT_TIMER1);
while(1)
{
if(had_timer1_interrupt)
{
output_toggle(PIN_A3);
had_timer1_interrupt = 0;
}
}
}
#INT_TIMER1
void timer1_handler()
{
had_timer1_interrupt=1;
} |
|
|