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

CCS Bootloader help

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



Joined: 13 Sep 2003
Posts: 87

View user's profile Send private message

CCS Bootloader help
PostPosted: Sun Mar 06, 2005 8:36 am     Reply with quote

I've use the CCS Bootloader included with my compiler version 3.188

Ive modified the code from the original ex_bootloader.c

Code:

if(!input(PIN_B4))
      load_program();


to

Code:

if(!input(PIN_B0)){
      output_low(PIN_A0);
      load_program();
      disable_interrupts(GLOBAL);
      delay_ms(250);
      FSR0H   = 0x00;
      PIR1    = 0x00;
      PIR2    = 0x00;
      TMR2    = 0x00;
      T2CON   = 0x00;
      PIE1    = 0x00;
      PR2     = 0xFF;
      STATUS  = 0x00;
      TMR0H   = 0x00;
      TMR0L   = 0x00;
      T0CON   = 0xFF;
      INTCON  = 0x00;
      INTCON2 = 0xFF;
      INTCON3 = 0xC0;
      T1CON   = 0x00;
      TMR1L   = 0x00;
      TMR1H   = 0x00;
      SPBRG   = 0x00;
      TXSTA   = 0x02;
      RCSTA   = 0x00;
      TXREG   = 0x00;
      RCREG   = 0x00;
      #asm reset #endasm
   }


My problem really is that my test code won't work... here's a pick of my test program..

Code:

#include <18F452.H>                    // Target PIC Microcontroller IC
#device  *=16                          // use a 16-bit pointer

#fuses HS,NOPROTECT,NOWDT,NOLVP    // PIC MCU Configuration
#use delay(clock=20000000)             // 20MHz Crystal clock speed

#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, enable=PIN_A1, parity=N, bits=8, errors)

#include <bootloader.h>
#include <LCD.C>

main()
{
   int count=0;

   delay_ms(2000);

   lcd_init();
   delay_ms(100);
   setup_adc_ports(NO_ANALOGS);

   printf(lcd_putc,"1234567890123456");
   printf(lcd_putc,"\nABCDEFGHIJKLMNOP");


   while (TRUE)
   {
      output_high(PIN_C1);
      output_low(PIN_A0);
      output_low(PIN_A2);
      delay_ms(2000);

      output_low(PIN_C1);
      output_high(PIN_A0);
      output_high(PIN_A2);
      delay_ms(2000);

      printf("\r\nThis is an RS485 Communication Test %03U",count);
      count++;
   }
}


I made a test case.

test case 1:
I remove all LCD related code stuff (remove printf, count, lcd_init) and the program will load successfully.

but for test case 2:
I include all the code mention above but this is where the problem occurs, after bootloading the test code won't work.

I also try to use the internal eeprom to save a marker such that after software reset it will read the internal eeprom and check if it needs to bootload a new firmware.

I can't be successfull using the internal eeprom.

Anybody can help me on this... I need your comments and suggestions.

Thank you.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 06, 2005 11:16 am     Reply with quote

If you make changes to code and then it doesn't work, then:

1. Comment out all your changes. Re-compile and see if the
program starts working again. (If it still doesn't work, then
start over with a clean copy of the original, working program.
Add your changes, but keep them commented out.)

2. Start to un-comment your changes a few lines at a time.
(Try to choose lines of code that are logically related, when you
do the un-commenting). Re-compile each time. At some
point, the code will start to fail.

3. Now work on just the group of lines that caused the failure.
Comment them out, one at a time. At one particular line,
the program will start working. Study this line. Read the
data sheet. Think in your mind about what peripherals or
i/o pins, or interrupts this line of code might affect. When
you do this, you will have found the problem.


This type of trouble-shooting procedure might not work in every case,
but it's a good place to start.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Mar 06, 2005 5:13 pm     Reply with quote

The bootloader example in v3.188 contains a bug.
In loader.c change:
Code:
                           erase_program_eeprom(addr);
                  #endif

to:
Code:
                           erase_program_eeprom(addr);
                     next_addr = addr + 1;
                  #endif
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