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 CCS Technical Support

#RDA does not work with Bootloader include

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



Joined: 26 Feb 2013
Posts: 30
Location: Algeria

View user's profile Send private message

#RDA does not work with Bootloader include
PostPosted: Sat Feb 21, 2015 6:29 am     Reply with quote

Hi guys, I am trying to develop a program in CCS Compiler Version 5 on RS232 communication between two PIC 18F4550 and 18F4620 I use #RDA interruption for the reception and it works very well except that I a problem when I included the "Bootloader.h" in this case the bootloader works well but it causes me a problem at #RDA because it does not work.

All work well without include bootloader.

Please a solution to this problem ...

This is my CCS prog:
Code:
#include <18F4620.h>
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES PUT                      //Power Up Timer
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES PBADEN                   //PORTB pins are configured as analog input channels on RESET
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES MCLR                     //Master Clear pin enabled
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTC                   //Configuration registers not write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads

#use delay(crystal=27000000)
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors)
//#use rs232(baud=9600,parity=N,xmit=PIN_B7,bits=8,stream=xbee)


#include <bootloader.h>

    volatile float   Voltage_IV[75];
    volatile float   Current_IV[75];
    volatile float   Power_IV[75];                     
    int w, incr1 = 0;
//------------------------------------------------------------------------------
   
   #INCLUDE <stdlib.h>
   #include <string.h>
   #include <tones1.c>
   #include <ds1307.c>
   #include <24512MODIF.c>
   #include <external_eeprom.c>
   #include <Extended_GLCD.c>
   #include "menu.c"

//-----------------------------------------------------------------------------

  signed int enc_states[] = {0,-1,1,0,0,0,0,0,0,0,0,0,0,1,-1,0};
  int16 enc_position = 0;
  int16 old_enc_value = 0;
  //volatile int  counter_read=0;
  volatile Char Recieve_String[6];
  volatile Char volt[4];
  volatile Char current[4];
  volatile Char Irr[5];
  volatile Char Tmp[5];
 
//*****************************************************************************
#int_rb
void Encoder_signal(void)
  {     
    enc_position >>= 2;                                        // shifting the lower bits up 2
    enc_position |= ( input_b() & 0B00110000 );                //port b, then OR them with var                                                                          //old_AB to set new value
    enc_value += enc_states[( enc_position & 0x0f )];
    if ( enc_value == old_enc_value ) { return;}
    old_enc_value = enc_value;
  }       
//*****************************************************************************
#int_RDA
void  RDA_isr(void)
{
   gets(Recieve_String);
//_______________________________________________________
   if (Recieve_String[0] == 'V')
   {
   memmove(Recieve_String,Recieve_String+1,6);
   strncpy(volt, Recieve_String,3);   
   keepv = atof(volt);
   maxvtab[i] = keepv * 6;
   Recieve_String[12] = 0;
   }
//_______________________________________________________
   if (Recieve_String[0] == 'C')
   {
   memmove(Recieve_String,Recieve_String+1,6);
   strncpy(current, Recieve_String,3);   
   keepi = atof(current);
   maxitab[i] = keepi * 2;
   Recieve_String[12] = 0;
   }
//_______________________________________________________
   if (Recieve_String[0] == 'T')
   {
   memmove(Recieve_String,Recieve_String+1,6);
   strncpy(Tmp, Recieve_String,5);   
   keepTmp = atof(Tmp);
   maxTmptab[i] = keepTmp;
   Recieve_String[12] = 0;
   }
//_______________________________________________________
   if (Recieve_String[0] == 'I')
   {
   memmove(Recieve_String,Recieve_String+1,6);
   strncpy(Irr, Recieve_String,4);   
   keepIrr = atof(Irr);
   maxIrrtab[i] = keepIrr;
   Recieve_String[12] = 0;
   }
   
   //_______________________________________________________
   if (Recieve_String[0] == 'A')
   {
         memmove(Recieve_String,Recieve_String+1,6);
         strncpy(volt2, Recieve_String,(strlen(Recieve_String)-1));
         vtab  = atof(volt2);
         Voltage_IV[w] = vtab;
         w++;
         incr1++;
         if (incr1==2) {incr1 = 0; incr++;}
   }
   //_______________________________________________________
   if (Recieve_String[0] == 'B')
   {
         memmove(Recieve_String,Recieve_String+1,6);
         strncpy(current2, Recieve_String,(strlen(Recieve_String)-1));
         itab  = atof(current2);
         Current_IV[w] = itab;
         w++;
         incr1++;
         if (incr1==2) {incr1 = 0; incr++;}
   }
   //_______________________________________________________
   if (Recieve_String[0] == 'F')
   {
         nextvalue = 1;
   }
}
//*****************************************************************************

void main()
{
   setup_adc_ports(AN0|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   //setup_ccp1(CCP_PWM|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L);
   setup_timer_2(T2_DIV_BY_1,224,1);      //33,3 us overflow, 33,3 us interrupt
 
   enable_interrupts(INT_RB);
   enable_interrupts(GLOBAL);
//*****************************************************************************
   //R = (700 * log10(2))/(log10(897));
   glcd_init(ON);
   ds1307_init();
   init_ext_eeprom();
   glcd_image(YES);
   //for (int16 v = 0; v <= 637; v++) {set_pwm1_duty(fade[v]); delay_ms(3);}
   generate_tone(D_NOTE[3], 100);
   enable_interrupts(INT_RDA);
   delay_ms(1000);
   enc_value = 1;
   PRmenu();
   
//*****************************************************************************
   
   while (true)
   {
//-----------------------------------------------------------------------------
   while (inter == 1)
    { 
       Sub_scrolling_PRmenu();

    }
//-----------------------------------------------------------------------------
   while (inter == 2)
    { 
       Lantch_IV_PV_extractor();
       if (choose == 1) { cadran_IV_PV(); choose = 0;while( !input(valid) ) {}
                         while (input(valid)){}}
       
                                delay_ms(50); disable_interrupts(INT_RDA);
                                enable_interrupts(INT_RB);acces_menu1 = 1;
                                enc_value = 3; inter = 0;PRmenu();
    }
//-----------------------------------------------------------------------------
    while (inter == 3)
    { 
       Voltage_measuring_and_ploting();
       Current_measuring_and_ploting();
    }
//-----------------------------------------------------------------------------
    while (inter == 4)
    { 
       Irradiation_measuring_and_ploting();
       Temperature_measuring_and_ploting();   
    }
//-----------------------------------------------------------------------------
    while (inter == 5)
    { 
       Panel_Parameters();
       delay_ms(1500);
       enc_value = 1; inter = 0;PRmenu();acces_menu1 = 1;
    }
//-----------------------------------------------------------------------------
    while (inter == 6)
    { 
       while( !input(valid) ) {if (enc_value <= 29) {enc_value = 29;}
                               if (enc_value >= 79) {enc_value = 79;}
                               set_pwm1_duty(fade[enc_value * 8]);
                               glcd_setxy(40,30,1,1);
                               printf(glcd_putc57, "%Lu ",((enc_value - 29)*2)); }
       while (input(valid)){}  enc_value = 1; inter = 0;
                               PRmenu();acces_menu1 = 1;
                             
    }
//-----------------------------------------------------------------------------
    while (inter == 7)
    { 
       diag_report();
       while (!input(valid)) {}
       while (input(valid)) {}
       enc_value = 3; inter = 0;PRmenu();acces_menu1 = 1;
    }
//-----------------------------------------------------------------------------
   scrolling_PRmenu();
   
   }
}
//*****************************************************************************


This the bootloader
Code:
#include <18F4620.h>
#fuses NOWDT
#use delay(crystal=27MHz)
#use rs232(baud=57600, xmit=PIN_A3, rcv=PIN_A2)
#define PUSH_BUTTON PIN_A4

#define _bootloader
#include <bootloader.h>
#include <loader.c>

 #org LOADER_END+2,LOADER_END+4

void application(void) {
  while(TRUE);
}

void main(void) {

   if(!input(PUSH_BUTTON))
   {
      printf("\r\nBootloader Version 1.0\r\n");
   
      // Let the user know it is ready to accept a download
      printf("\r\nWaiting for download...");
      load_program();
   }

   application();
}

#int_global
void isr(void) {
   jump_to_isr(LOADER_END+5*(getenv("BITS_PER_INSTRUCTION")/8));
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sat Feb 21, 2015 1:27 pm     Reply with quote

First, the _bootloader_ needs all the fuses. Get rid of them in the runtime. Personally I use #fuses NONE in the runtime code. You can't change fuses in the application, from what the bootloader has.
Then your interrupt is fundamentally flawed. INT_RDA, means _one_ character is available. Just one. Do a search here for why you should never use gets in the interrupt. I'd suspect your failure is actually caused by the extra delay on boot, and the interrupt not functioning as you expect, rather than the bootloader itself....
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