Constants aloccation in ROM by address compilator fail

General discussion on mikroC PRO for PIC.
Author
Message
renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: Constants aloccation in ROM by address compilator fail

#16 Post by renew » 11 Dec 2022 22:44

No, don't touch a Flash zone, I know it will work.
I can't use a Flash, for this reason.
Pic 1855 USB downloader on pic 18877 demo board is not able to write a Flash zone, so I am forced to use programm memory zone.

I have an idea to use ASM{} commands to read constants from ROM
Back to the roots 🤣
But I could check it later, in the one week trip now.

paulfjujo
Posts: 1555
Joined: 24 Jun 2007 19:27
Location: 01800 St Maurice de Gourdans France
Contact:

Re: Constants aloccation in ROM by address compilator fail

#17 Post by paulfjujo » 12 Dec 2022 11:32

renew wrote:
11 Dec 2022 22:44
No, don't touch a Flash zone, I know it will work.
I can't use a Flash, for this reason.
Pic 1855 USB downloader on pic 18877 demo board is not able to write a Flash zone, so I am forced to use programm memory zone.

I have an idea to use ASM{} commands to read constants from ROM
Back to the roots 🤣
But I could check it later, in the one week trip now.
:!: for me, Flash and program memory zone is the same !

if you have a USB downloader ( as on StartUSB 18F250 Mikroelectronika)
maybe you can change somme data in flash (program memory zone) by using virtual serial COM trough USB link !
( HID_Read()); to get your new data
and FLASH mikroC Library , with a few additional code . to change data in Rom

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: Constants aloccation in ROM by address compilator fail

#18 Post by renew » 12 Dec 2022 14:39

My project is based on microchip DM164142 demo board, with usb loader . It can't to flash Flash zone cells, I tried.
I can show any info on the display, same thing as UART.

paulfjujo
Posts: 1555
Joined: 24 Jun 2007 19:27
Location: 01800 St Maurice de Gourdans France
Contact:

Re: Constants aloccation in ROM by address compilator fail

#19 Post by paulfjujo » 12 Dec 2022 16:08

renew wrote:
12 Dec 2022 14:39
My project is based on microchip DM164142 demo board, with usb loader . It can't to flash Flash zone cells, I tried.
I can show any info on the display, same thing as UART.
OK,

but your application can do it !
After uploading your program into the PIC via the bootloader
you can send new data trough UART link with a special protocol (defined by you!) example send "Flash1770=0X05"
treat the receveived string to extract the new data by your application (your running program )
then change data in Flash Zone ..
not concerned by bootloader limitation !
......except if you want to write into the bootloader application itself...

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: Constants aloccation in ROM by address compilator fail

#20 Post by renew » 12 Dec 2022 16:22

Yes, you are right.
But my goal - the users should to be able to change cells during programming PIC to change some parameters of device. My device has only one button so I can't implement a menu.
I mean the cell changing method should be as easier as it's possible.

renew
Posts: 28
Joined: 24 Nov 2016 13:56

Re: Constants aloccation in ROM by address compilator fail

#21 Post by renew » 18 Dec 2022 00:29

Hi.
I don't know what is happened, but it started to work now
I just do for pic 1939

Code: Select all

const char Cells[10] = {0x05, 0x30, 0x08, 0x10, 0x15, 0x13, 0x01, 0x04, 0x14, 0x60} absolute 0x2220;
char Cells_2[10];
volatile char a;

void func (void{
        char i;
        char txt[5];
        
        for(i=0; i<10; i++){
           Cells_2[i] = Cells[i];
        }
        for(i=0; i<10; i++){
           a = Bcd2Dec(Cells_2[i]);
           ShortToStr(a, txt);
           oled_write(i+1, 0, txt, 5, 'w');
        }
}
And I can to chage cells externally and it works ! Optimisation level Four.

But I have found some other glitch connected with long

Code: Select all

a = 1000 * 10 * 10;       // first case
a = 100000;                 // second case
LongToStr(a, txt);
oled_write(2, 0, txt, 12, 'w');
In the first case result is -31072
In the second 100000

Post Reply

Return to “mikroC PRO for PIC General”