Author Topic: Programming PIC16628A- Program section is written but EEPROM is not written  (Read 1004 times)

0 Members and 1 Guest are viewing this topic.

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Dear All,

I am trying to write a HEX file into the PIC16F628 using a PICkit-2 compatible programmer. The HEX file was produced using MikroC Pro for PIC.

Please see 2 attached pictures (Before and After HEX file loading).

Following is the relevant code segment:
//////
// TIMER project at DIYfan.blogspot.com  /Modified by Psyklops/Asadul Huq
//PIC16F628A--4mhz external Crystal osc. Compiler MikroC pro for PIC v7.6
//Note:
//This timer starts without a trigger and as soon as power is applied with a
//preset time stored in EEPROM. AH. 27-08-2020
 //Code V.12 AH. 04-09-2020

#define OneSecondDefault 977 // default value for OneSecond

#define my_delay_30() Delay_ms(30)
#define my_delay_50() Delay_ms(50)
#define my_delay_500() Delay_ms(500)
#define my_debounce() Delay_ms(100)


// LCD pins
 sbit LCD_RS at RA1_bit;
 sbit LCD_EN at RA0_bit;
 sbit LCD_D4 at RB7_bit;
 sbit LCD_D5 at RB6_bit;
 sbit LCD_D6 at RB5_bit;
 sbit LCD_D7 at RB4_bit;
 sbit LCD_RS_Direction at TRISA1_bit;
 sbit LCD_EN_Direction at TRISA0_bit;
 sbit LCD_D4_Direction at TRISB7_bit;
 sbit LCD_D5_Direction at TRISB6_bit;
 sbit LCD_D6_Direction at TRISB5_bit;
 sbit LCD_D7_Direction at TRISB4_bit;

//Output settings
 sbit SND at RA2_bit;          // define beep sound pin
 sbit OUT at RB3_bit;           // define Relay OUT pin
 sbit RUN_IND at RA4_bit;
 sbit END_ALARM at RA3_bit;

// PUSH BUTTON connections
 sbit START_sw at RA5_bit;
 sbit RESET_sw at RB0_bit;
 sbit MIN1_sw at RB1_bit;    // MIN1 = (MIN++) button
 sbit MIN2_sw at RB2_bit;     // MIN2 = (MIN--) button

// Variables
int cnt, OneSecond; // tmp;
unsigned short seconds, minutes, sound_sec;
unsigned short Set_seconds, Set_minutes;
bit a, start, oldF1;
//char str1[6];

 void Read_EEPROM() {                      ////Load from eeprom
 if (EEPROM_Read(0x16) == 1){
  my_delay_30();
  minutes = EEPROM_Read(0x11);
  my_delay_30();
  seconds = EEPROM_Read(0x12);
  my_delay_30();
 }
}

void Write_EEPROM() {
     Delay_100ms();
     EEPROM_Write(0x16,1);
     my_delay_50();
     //EEPROM_Write(0x12,seconds);
     EEPROM_Write(0x12,0);
     my_delay_50();
     EEPROM_Write(0x11,minutes);
     my_delay_50();
     //EEPROM_Write(0x10,hours);
     //Delay_ms(50);
}

 ... ////////////////////////////////////

Please note that the complete code is attached bellow.

Seems that the Program memory section is written successfully. However, the EEPROM data storage section is not written (Please see figure-After. All locations are FF). By the way, while I simulate with the Proteus, the PIC is loaded with the HEX file data. When simulation starts EEPROM data is loaded. So, in the Proteus EEPROM data is loaded successfully. Does not it mean that the HEX file contains the EEPROM data? But that data is not written in the PIC in real life.
I will appreciate it so much if one can assist me to solve the issue. Thanks.
« Last Edit: September 05, 2020, 03:51:35 pm by asadulhuq »
 

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 195
  • Country: gb
Re: Programming PIC16628A- Program section is written but EEPROM is not written
« Reply #1 on: September 05, 2020, 08:45:50 am »
Hi,

You need to show your program code.
Simulation programs can work differently to actual programming up.
 

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Programming PIC16628A- Program section is written but EEPROM is not written
« Reply #2 on: September 05, 2020, 08:51:19 am »
Thanks. I will attach the source program with the original question.
« Last Edit: September 05, 2020, 08:53:26 am by asadulhuq »
 

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Programming PIC16628A- Program section is written but EEPROM is not written
« Reply #3 on: September 05, 2020, 03:17:32 pm »
Hi there,
Complete code is now attached with the original post. Please have a look. Thanks.
 

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 195
  • Country: gb
Re: Programming PIC16628A- Program section is written but EEPROM is not written
« Reply #4 on: September 05, 2020, 03:40:22 pm »
Hi,

Not into Mikro C, so hopefully others can help out with the detail,  but from your code you show a routine for Reading from EEprom and one for Writing Data to EEprom for use once your code is running.

Your question seems to say you want to load EEprom with data at programming time, but you do not appear to have any code to do that.
Expect something along these lines is whats needed in your code to load EEprom with data, with the correct memory location for the chip you are using,

 __EEPROM_DATA(0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07);

or

 #pragma romdata eedata_scn=0xf00000
 rom eedata_values[8] = {0, 1, 2, 3, 4, 5, 6, 7};
 #pragma romdata


Again not into MikroC but your code does not appear to have any Config Bits, though do not know if thats done separately in MikroC  ?
« Last Edit: September 05, 2020, 03:43:49 pm by Lindley »
 

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Programming PIC16628A- Program section is written but EEPROM is not written
« Reply #5 on: September 05, 2020, 03:53:57 pm »
Hello,
Now screenshot of config settings (for MikroC Pro for PIC) has been attached the main post. Thanks for your effort.
 

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 195
  • Country: gb
Re: Programming PIC16628A- Program section is written but EEPROM is not written
« Reply #6 on: September 05, 2020, 04:14:08 pm »
If you are wanting to load EEprom at programming time, seems MikroC has its own EEprom Editor tool , if thats what you are trying to do ?

 

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Programming PIC16628A- Program section is written but EEPROM is not written
« Reply #7 on: September 05, 2020, 04:53:13 pm »
Hello,
Yes i am trying to do that. However, I did not know that MikroC needed a separate tool to write preset data into the EEPROM during writing a PIC. Thanks for your information I will try to use that tool. 
 

Offline Bud

  • Super Contributor
  • ***
  • Posts: 6912
  • Country: ca
Re: Programming PIC16628A- Program section is written but EEPROM is not written
« Reply #8 on: September 05, 2020, 05:47:33 pm »
As Lindley said you do not seem to have EEPROM data initialization directives in your code, hence nothing is written in it during  chip programming. Can you point out the part in your code that you believe would initialize the EEPROM ?
Facebook-free life and Rigol-free shack.
 

Offline asadulhuqTopic starter

  • Contributor
  • Posts: 36
  • Country: bd
Re: Programming PIC16628A- Program section is written but EEPROM is not written
« Reply #9 on: September 06, 2020, 04:13:29 am »
Hi there. I am new to Microcontroller programming. I didn't know that I needed additional steps to record my preset data in EEPROM while downloading hex file into the Pic device. Furthermore, simulation with Proteus recorded preset data while I inserted hex file into the pic. So, I thought the hex file was complete and would store preset data into EEPROM storage section while burning the Pic. Now, I understand that I have to include additional code to store preset data in EEPROM in real life. Now, I shall add additional statements in the code to store preset data.Thanks again.
« Last Edit: September 06, 2020, 04:41:53 am by asadulhuq »
 
The following users thanked this post: Lindley


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf