renew wrote: ↑11 Dec 2022 12:45
Hi.
Yes, I understand, but I locate 1 char in 1 14 bit cell, it is absolutely possible. See the hex file screenshot, 1 constant in 2 bytes.
You need to return my post number 8.
I am sure that the compiler precalculates variables wich calculation based on constants.
i don't contest that ...
i did same test on my 16F1847
Source : _16F1847_Test_LCD_Open_Smart_Serial__2022-1211.c
------------------ original programm --------------------
1768 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF
1770 3401 3430 3408 3410 3415 3413 3401 3404
1778 3414 3460 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF
Test Forum MikroC :
viewtopic.php?f=88&t=79656
Cells 0> 1
Cells 1> 48
Cells 2> 8
Cells 3> 16
Cells 4> 21
Cells 5> 19
Cells 6> 1
Cells 7> 4
Cells 8> 20
Cells 9> 96
1 ,Cell_O =0x01
30 ,Cell_O =0x30
8 ,Cell_O =0x08
0x01,0x30,0x08
---------------------
manual change into Pickit3 program memory 3 values at 1770,1771,1772
1768 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF
1770 3412 3444 3418 3410 3415 3413 3401 3404
1778 3414 3460 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF
--------------------------
reload program into the PIC
Write Pickit3 command
get results :
Test Forum MikroC :
viewtopic.php?f=88&t=79656
Cells 0> 18
Cells 1> 68
Cells 2> 24
Cells 3> 16
Cells 4> 21
Cells 5> 19
Cells 6> 1
Cells 7> 4
Cells 8> 20
Cells 9> 96
1rst reading is OK !!!!
1 ,Cell_O =0x01
30 ,Cell_O =0x30
8 ,Cell_O =0x08
0x01,0x30,0x08
same strange behavior as yours !
the first reading take care about the change i made on the 3 first values
but is not permanent after ???
re use old setting !!
but were are stored old settings ?
remark : 0x34 as upper byte ? instead of 00 or FF
je donne ma langue au chat !
- adaladale_clavier.gif (244.61 KiB) Viewed 2058 times
Code: Select all
unsigned char Cell_0=0;
const unsigned char Cells[10] = {0x01, 0x30, 0x08, 0x10, 0x15, 0x13, 0x01, 0x04, 0x14, 0x60} absolute 0x1770;
// PIC16(L)F1847 8,192 word last adress= 1FFFh
// Up to 14 Kbytes Linear Program Memory
//The enhanced mid-range core has a 15-bit program
//counter capable of addressing a 32K x 14 program memory space. (errata 32K ?? for me 8192 word -> 16K bytes)
// ------------ test forum kikroE -------------------------------
CPrint( "\r\n Test Forum MikroC :\r\n");
CPrint("\r\n https://forum.mikroe.com/viewtopic.php?f=88&t=79656 \r\n");
for (i=0;i<10;i++)
{
ByteToStr( Cells[i],txt);
CPrint(" Cells ");
UART1_Write(i+48); UART1_Write('>');
Print(txt);
CRLF1();
}
CRLF1();
Cell_0 = Bcd2Dec(Cells[0]);
ShortToStr(Cell_0, txt);
Print(txt);
Cell_0 =Cells[0];
CPrint(" ,Cell_O =0x");ByteToHex(Cell_0,CRam1);Print(CRam1);
CRLF1();
Cell_0 = Bcd2Dec(Cells[1]);
ShortToStr(Cell_0, CRam1);
Print(CRam1);
Cell_0 =Cells[1];
CPrint(" ,Cell_O =0x");ByteToHex(Cell_0,CRam1);Print(CRam1);
CRLF1();
Cell_0 = Bcd2Dec(Cells[2]);
ShortToStr(Cell_0, CRam1);
Print(CRam1);
Cell_0 =Cells[2];
CPrint(" ,Cell_O =0x");ByteToHex(Cell_0,CRam1);Print(CRam1);
CRLF1();
CRLF1();
CPrint("0x");ByteToHex(Cells[0],CRam1); Print(CRam1);UART1_Write(',') ;
CPrint("0x");ByteToHex(Cells[1],CRam1); Print(CRam1);UART1_Write(',') ;
CPrint("0x");ByteToHex(Cells[2],CRam1); Print(CRam1);CRLF1();
while(1);
//----------------------------------------------------
Reading (and Writing) in Flash memory needs special function ...
Pickit3 surely can write in flash memory
but reading by a classic way (as reading in Ram) ,normaly, doesen't works ..
but why first reading works without use of FLASH library ?
plus fort que le roquefort !
i used Flash reading function
0x01,0x30,0x08
adresse= 0x1770:01
adresse= 0x1771:30
adresse= 0x1772:08
adresse= 0x1773:10
adresse= 0x1774:15
adresse= 0x1775:13
adresse= 0x1776:01
adresse= 0x1777:04
adresse= 0x1778:14
adresse= 0x1779:60
modif:
1768 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF
1770 3412 3420 3418 3430 3415 3413 3401 3404
1778 3414 3460 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF
Write to PIC and restart
Cells 0> 18
Cells 1> 32
Cells 2> 24
Cells 3> 48
Cells 4> 21
Cells 5> 19
Cells 6> 1
Cells 7> 4
Cells 8> 20
Cells 9> 96
1 ,Cell_O =0x01
30 ,Cell_O =0x30
8 ,Cell_O =0x08
0x01,0x30,0x08
adresse= 0x1770:12
adresse= 0x1771:20
adresse= 0x1772:18
adresse= 0x1773:30
adresse= 0x1774:15
adresse= 0x1775:13
adresse= 0x1776:01
adresse= 0x1777:04
adresse= 0x1778:14
adresse= 0x1779:60
i added this code
Code: Select all
j=0x1770;
for (i=0;i<10;i++)
{
CPrint(" adresse= 0x177"); UART1_Write(i+48); UART1_Write(':');
Cell_0= FLASH_Read(j);
ByteToHex(Cell_0,txt);Print(txt); CRLF1();
j++;
}
to read back Flash zone before and after modifying the programme Memory (via Pickit3)
and read back is OK !!
the changes are there !