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

Problem with write_program_memory

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



Joined: 23 Aug 2015
Posts: 3

View user's profile Send private message

Problem with write_program_memory
PostPosted: Sun Aug 23, 2015 7:15 am     Reply with quote

Hi

I'm trying to write an I2C Bootloader for the PIC16F1503, but I have a problem with the function write_program_memory().
Here is my source code just to test this function:
Code:

#include <16F1503.h>
#device ADC=16

#FUSES NOWDT                   
#FUSES NOBROWNOUT             
#FUSES NOLVP               


#use delay(internal=16MHz)
#use FIXED_IO( A_outputs=PIN_A0 )
#define LED   PIN_A0

#use i2c(Slave,Fast,sda=PIN_C1,scl=PIN_C0,address=0xA0)
#use rs232(baud=9600, xmit=PIN_C4,rcv=PIN_C5)


#ORG 0x700, 0x7FF {}
 
int8 buffer [32];
int8 to_write [32] = {0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB,0xAB};
int16 addr = 0x700;

void main()
{
   printf("Write Program Memory Test");


   int i =0 ;
   printf("\n\rBefore: \n\r");
   read_program_memory(addr,&buffer,32);
   
   for(i=0;i<32;i++){
      printf("%X " , buffer[i]);
   }

   
   write_program_memory(addr , &to_write,32);

   
   printf("\n\r");
   printf("\n\rAfter: \n\r");
   
   read_program_memory(addr,&buffer,32);
   
   for(i=0;i<32;i++){
      printf("%X " , buffer[i]);
   }


   printf("\n\r");


   while(1)
   { }

}


And here the output of the serial port:
Code:
Write Program Memory Test
Before:
FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F

After:
FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F FF 3F



I thought this code should change at least anything.
But it doesn't change anything, I can't find the problem, so some help would be appreciated.
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 10:35 am     Reply with quote

Repeat five times. Compiler version?....

It's possible (probable) that the supplied code may not work. Quite a few compilers have faults in their code for this.

Have a look at this thread:
<http://www.ccsinfo.com/forum/viewtopic.php?t=54018&highlight=mywriteprogrammemory>

Where I posted a 'from the data sheet' version of write_program_memory.

However also notice that the primary problem was that the chip was write protected.....
Martin525



Joined: 23 Aug 2015
Posts: 3

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 11:22 am     Reply with quote

Thanks for your help.
Your Function is doing a great job.
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 1:46 pm     Reply with quote

Good.

What compiler version though?.
If it is a 'current' compiler, this needs to be reported, so tell us please.
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

PostPosted: Sun Aug 23, 2015 3:53 pm     Reply with quote

Ttelmah wrote:
Good.

What compiler version though?.
If it is a 'current' compiler, this needs to be reported, so tell us please.


Let me guess 4.084 Twisted Evil
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
Martin525



Joined: 23 Aug 2015
Posts: 3

View user's profile Send private message

PostPosted: Mon Aug 24, 2015 5:32 am     Reply with quote

My Compiler Version is 5.007, 27506.
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

PostPosted: Mon Aug 24, 2015 5:37 am     Reply with quote

Martin525 wrote:
My Compiler Version is 5.007, 27506.


Unless you have a specific reason ... please upgrade to 5.048.

5.007 is an early release (Beta) of v5 compiler!
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Mon Aug 24, 2015 5:38 am     Reply with quote

OK. 5.007, is a very early V5 compiler. Really still likely to be a bit 'beta'. Not surprising it has problems then.
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