View previous topic :: View next topic |
Author |
Message |
Greg Richter
Joined: 15 Feb 2008 Posts: 18 Location: Atlanta, Tulsa, Asheville
|
Bootloader #global ISR conflict |
Posted: Thu Sep 26, 2024 4:02 pm |
|
|
Using the CCS bootloader and get an unexpected conflict between the global ISR they use to replace the default, now relocated, handler and #INT_TIMER0.
Do I have to handle the timer ISRs manually if using the bootloader code?
Code is:
void main()
{
setup_adc(ADC_CLOCK_DIV_32); // 2 us at 16 MHz
setup_adc_ports(ANALOGS); // configure AD ports defined above, Vss-Vdd
setup_timer_0(RTCC_INTERNAL|T0_DIV_16|T0_8_bit); // f = 16MHz / 4 * 16 * 256 = 976.56 Hz, which scans 976/8 ~= 122 Hz refresh to LEDs
enable_interrupts(INT_TIMER0); // start timer ISR
enable_interrupts(GLOBAL); // ... and everyone else
setup_wdt(WDT_4S); // reboot after 4s of no reset for your doooogie
ReadADs(); // preload to get something on displays during tension reset
TreatmentStopReset(); // return to zero
while(TRUE)
{
restart_wdt(); // note we are still running ...
ReadADs(); // get ADs from pots and sensors
SetOttomanAngle(); // follow control setting
TreatmentStateMachine(); // run treatment state machine
if(IsStopTreatment) TreatmentStopReset(); // stop if flagged
if(IsReturnToZero && !RTZCounter) // check if we are in RTZ
{
IsReturnToZero = 0; // RTZ complete
output_low(PWM_TENSION); // motor off
output_low(PWM_TENSION_DIR); // relay in forward mode
delay_ms(10); // wait for relay to move
}
JustOnce=0; // for init things we do one time
}
}
#int_global
void isr(void) {
jump_to_isr(LOADER_END+5*(getenv("BITS_PER_INSTRUCTION")/8));
}
Errors reported are:
*** Error 159 "C:\xxx\acc.c" Line 557(16,17): Invalid interrupt directive Can not mix GLOBAL with non-global _________________ Madness takes it toll; please have exact change. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19495
|
|
Posted: Fri Sep 27, 2024 12:14 am |
|
|
It looks as if you are trying to use a timer interrupt inside the bootloader.
Don't.
Just poll the timer interrupt flag. Honestly a bootloader should be as small
and simple as possible.
The bootloader adds code to relocate all the interrupts for use in the
main non bootloader application. If you use the timer interrupt in the
bootloader this will interfere with this relocation.
It is possible to use an interrupt in both, but doing so, means much
more complexity and will slow things down. Honestly better never to
do so.
However what you post is puzzling. This looks like main non bootloader
code, butt you have the relocation that should only be inside the actual
bootloader with it. Does not look right.
That relocation code should only be inside the actual bootloader, not
in the code that is loaded by the bootloader.
Look at ex_bootload.c for an example of a program loaded by the
bootloader. Note the interrupt relocation is not in this. |
|
|
Greg Richter
Joined: 15 Feb 2008 Posts: 18 Location: Atlanta, Tulsa, Asheville
|
|
Posted: Fri Sep 27, 2024 3:48 pm |
|
|
Got it sorted -- two modules. THX! _________________ Madness takes it toll; please have exact change. |
|
|
|