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

write_configuration_memory fails ??

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



Joined: 25 Oct 2004
Posts: 136

View user's profile Send private message

write_configuration_memory fails ??
PostPosted: Wed Feb 10, 2010 1:45 am     Reply with quote

Hi,

I am trying to make a repair programm because the initial bootloader had the BORV set wrong.

So I was thinking of doing the following:

define: int data[6]

read_configuration_memory[data,6];
change data[1] to new content
write_configuration_memory[data,6];

..... it hangs up !

any suggestions ??

appriciate your help

best regards

Andreas


Code:

#define SDL32

#define Master_Slave
#define NewAtmel
#define IntGPRS

#define GPRSActive

#define LCD4X20
#define NewGSM


//#define Bootloader      // Define for using with bootloader only !!
//#undef bootloader

#include "C:\SDL_All_Versions\SDL32_Intern_GPRS\SDL32_Intern_GPRS.h"
#include <string.h>
#include <stdio.h>
#include "C:\SDL_All_Versions\SDL32_Common\LCD420_8B.c"

#ifdef Bootloader
   #include "C:\SDL_All_Versions\SDL32_Intern_GPRS\Bootloader_New_SDL32_GPRS.h" 
#endif




int data[6];


void main()
{
      // Set All Output Signals to Init Values
      // Flash Interface Signals
set_tris_B(0xff);
set_tris_E(0x00);
Set_Tris_H(0xff);                   // Set All Keyboard Lines to Input
Output_Low(E_Input);       // Input Latches Enable Line
Output_Low(E_OUT);      // Disable Output Latch
Output_Low(LCD_EN);      // Disable LCD Enable Pin
Output_Low(RS);         // LCD Command Line
Output_High(RW);         // LCD Read/Write Line
Output_High(RReset);          // RAM Reset
Output_Low(RReset);           // RAM Reset
Output_High(RReset);          // RAM Reset
Output_High(ROut_E);          // RAM Output Enable
Output_High(RDir);            // RAM Data Direction Set to Write to Flash
Output_High(E_Out_Buffer);    // Disable Output Driver
Output_High(WP);              // Page Write Protect NOT USED
Output_High(RB_2);
Output_High(RB_3);
Output_High(RB_4);
Output_High(CS_1);             // -Chip Select for RAM
Output_High(CS_2);
Output_High(CS_3);
Output_High(CS_4);
Output_High(CS_RAM);
                              // Output Driver Interface
OutLatch = 0x00;            // Clear Output Latch Variable
                            // LED Backlight Control
Output_High(BackLight);     // Switch Off for ModemControl
Output_High(CLK);           // Set Clk for Polarity Low Timing



      // General Setups

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
 
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DIV_BY_16,0xFF,8);
   setup_timer_3(T3_INTERNAL|T3_DIV_BY_1);
   setup_ccp2(CCP_PWM);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   set_timer3(0xFA20);


lcd_init();                         // Init LCD Display

  switch ( restart_cause() )
   {
      case WDT_TIMEOUT:
         {
         lcd_gotoxy(1,4);
         lcd_putc("Watch DOG Reset");
         break;
         }
      case NORMAL_POWER_UP:
         {
         lcd_gotoxy(1,4);
         lcd_putc("Power Up Reset");
         break;
         }
      case MCLR_FROM_SLEEP:
         {
         lcd_gotoxy(1,4);
         lcd_putc("Reset from Sleep");
         break;
         }
      case MCLR_FROM_RUN:
         {
         lcd_gotoxy(1,4);
         lcd_putc("Reset Button");
         break;
         }
      case BROWNOUT_RESTART:
         {
         lcd_gotoxy(1,4);
         lcd_putc("Brown Out Reset");
         break;
         }
      case WDT_FROM_SLEEP:
         {
         lcd_gotoxy(1,4);
         lcd_putc("WDT from Sleep Reset");
         break;         
         }
      case RESET_INSTRUCTION:
         {
         lcd_gotoxy(1,4);
         lcd_putc("Reset Instruction");
         break;         
         }
      }


lcd_gotoxy(1,1);
read_configuration_memory(data,6);

Disp_Hex (data[0]);
Disp_Hex (data[1]);
Disp_Hex (data[2]);
Disp_Hex (data[3]);
Disp_Hex (data[4]);
Disp_Hex (data[5]);

     
delay_ms(10000);

data[1] = 0x1E;
lcd_gotoxy(1,2);

Disp_Hex (data[0]);
Disp_Hex (data[1]);
Disp_Hex (data[2]);
Disp_Hex (data[3]);
Disp_Hex (data[4]);
Disp_Hex (data[5]);

write_configuration_memory(data,6); 

reset_cpu();


delay_ms(2000);

lcd_gotoxy(1,3);
read_configuration_memory(data,6);

Disp_Hex (data[0]);
Disp_Hex (data[1]);
Disp_Hex (data[2]);
Disp_Hex (data[3]);
Disp_Hex (data[4]);
Disp_Hex (data[5]);

     
} //main


Ttelmah
Guest







PostPosted: Wed Feb 10, 2010 3:11 am     Reply with quote

First, what chip....
Then, you are executing 'reset_cpu' after writing. It won't ever get to the program beyond this. Reset_cpu, makes the code restart.

Best Wishes
Guest








PostPosted: Wed Feb 10, 2010 3:18 am     Reply with quote

Hi Ttelmah,

Thanks for the quick reply !

Yes You are right I removed it already, was a thinking loop -:(

I found now, that the program hangs after write_configuration_memory !

Chip : 18F8722

I cant find any hint on how it should really work, the manual is not very detailed in that !

best regards
ANdreas
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Feb 10, 2010 4:31 am     Reply with quote

If int means int8 in your code, you're not writing to the BORxx bits. Byte 1 is CONFIG1H (FOSCx).
Generally, if you don't know what a built-in function actually does, look at the generated code or trace it with
MPLAB SIM or assembly level debug.
Andreas



Joined: 25 Oct 2004
Posts: 136

View user's profile Send private message

PostPosted: Wed Feb 10, 2010 6:15 am     Reply with quote

Hi FvM,

That was the perfect hint, I was mixing up high and low Byte, because in the Config table in the microchip manual it starts with 300001h BUT this is the 1H Byte and not the 1L Byte !

Many thanks for Your help.

Best regards out of vienna
Andreas
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