|
|
View previous topic :: View next topic |
Author |
Message |
Martin525
Joined: 23 Aug 2015 Posts: 3
|
Problem with write_program_memory |
Posted: Sun Aug 23, 2015 7:15 am |
|
|
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: 19539
|
|
Posted: Sun Aug 23, 2015 10:35 am |
|
|
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
|
|
Posted: Sun Aug 23, 2015 11:22 am |
|
|
Thanks for your help.
Your Function is doing a great job. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Aug 23, 2015 1:46 pm |
|
|
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
|
|
|
Martin525
Joined: 23 Aug 2015 Posts: 3
|
|
Posted: Mon Aug 24, 2015 5:32 am |
|
|
My Compiler Version is 5.007, 27506. |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Mon Aug 24, 2015 5:37 am |
|
|
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: 19539
|
|
Posted: Mon Aug 24, 2015 5:38 am |
|
|
OK. 5.007, is a very early V5 compiler. Really still likely to be a bit 'beta'. Not surprising it has problems then. |
|
|
|
|
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
|