|
|
View previous topic :: View next topic |
Author |
Message |
pbraida
Joined: 02 Feb 2011 Posts: 14
|
PIC 24EP512GU810 Bootloader problem |
Posted: Fri Jun 03, 2016 5:22 am |
|
|
First sorry for the bad English.
My compiler version is 5.059.
I am try to use the example: pcd_aux_bootloader.
My board has a PIC24EP512GU810 like the example, the bootloader works well. The firmware download occurs with no errors. The problem is when the board re-boots, it never enters in the application program, and if I press the button the bootloader starts again.
I use the example with no notification, the only one is the com port I use is UART2.
Thanks for any help. |
|
|
pbraida
Joined: 02 Feb 2011 Posts: 14
|
|
Posted: Fri Jun 03, 2016 8:06 am |
|
|
This is the code for bootloader:
Code: |
#define ROM_WRITE_CAN_MODIFY_CONFIG_BITS
#include <24EP512GU810.h>
#fuses NOWDT,RESET_AUX //The RESET_AUX fuse causes PIC to reset into Auxiliary Memory
#build (AUX_MEMORY) //Build code for Auxiliary Memory
#use delay(clock=120MHz,crystal=8MHz)
#pin_select U2TX=PIN_E2
#pin_select U2RX=PIN_E3
#use rs232(baud=9600,UART2,errors)
#define PUSH_BUTTON PIN_B9
#define LED1 PIN_A0
#define LED2 PIN_A1
//The following defines are necessary to use PCD's serial bootloader, loader_pcd.c.
#define _bootloader
#define LOADER_SIZE 0
#define APPLICATION_START 0
#define APPLICATION_END getenv("PROGRAM_MEMORY")
//Include PCD's serial bootloader
#include <loader_pcd.c>
#INT_AUX
void auxialary_isr(void)
{
if(interrupt_enabled(INT_TIMER1) && interrupt_active(INT_TIMER1))
{
output_toggle(LED1);
clear_interrupt(INT_TIMER1);
}
if(interrupt_enabled(INT_TIMER2) && interrupt_active(INT_TIMER2))
{
output_toggle(LED2);
clear_interrupt(INT_TIMER2);
}
}
void main(void)
{
set_pullup(TRUE,PIN_B9); // BOTAO 1
set_pullup(TRUE,PIN_B10); // BOTAO 2
set_pullup(TRUE,PIN_B11); // BOTAO 3
if(!input(PUSH_BUTTON))
{
delay_ms(140); // wait for PLL
printf("\r\nBootloader Version 1.0\r\n");
// Let the user know it is ready to accept a download
printf("\r\nWaiting for download...");
setup_timer1(TMR_INTERNAL | TMR_DIV_BY_256, 58593); //~250 ms period
setup_timer2(TMR_INTERNAL | TMR_DIV_BY_256, 23437); //~100 ms period
enable_interrupts(INT_TIMER1);
//! enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
// Load the program
load_program();
}
goto_address(APPLICATION_START);
}
This is the app code:
#include <24EP512GU810.h>
#fuses NOWDT,RESET_AUX
#use delay(clock=120MHz, crystal=8MHz)
#pin_select U2TX=PIN_E2
#pin_select U2RX=PIN_E3
#use rs232(baud=9600,UART2,errors)
#define PUSH_BUTTON PIN_D6
#define LED1 PIN_A0
#define LED2 PIN_A1
#define LED3 PIN_A2
rom char version[] = "Application Version 1.0";
void DisplayLeds(unsigned int8 Led)
{
output_low(LED1);
output_low(LED2);
output_low(LED3);
switch(Led)
{
case 0:
output_high(LED1);
break;
case 1:
output_high(LED2);
break;
case 2:
output_high(LED3);
break;
}
}
#INT_TIMER1
void led_isr(void)
{
static unsigned int8 Led = 0;
DisplayLeds(Led);
if(++Led >= 3)
Led = 0;
}
void main()
{
set_pullup(TRUE,PIN_B9); // BOTAO 1
set_pullup(TRUE,PIN_B10); // BOTAO 2
set_pullup(TRUE,PIN_B11); // BOTAO 3
delay_ms(100);
printf("\r\n%s\r\n", version);
printf("You can put whatever code you want here.\r\n");
printf("So enjoy!\r\n");
setup_timer1(TMR_INTERNAL | TMR_DIV_BY_256, 46874); //200 ms period;
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while(TRUE)
{
restart_wdt();
}
} |
Any ideas, this code is a CCS example the only change to the original one is the UART number.
Thanks. |
|
|
|
|
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
|