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

PIC 24EP512GU810 Bootloader problem

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



Joined: 02 Feb 2011
Posts: 14

View user's profile Send private message

PIC 24EP512GU810 Bootloader problem
PostPosted: Fri Jun 03, 2016 5:22 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 03, 2016 8:06 am     Reply with quote

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.
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