This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems in saving (and parameter passing ) a 32 bit value in the flash.

I need to save a 32 bit variable to the flash. I am using the In Application Programming.I wrote a code starting from the function "program data byte" (in my case I made program_data_dword).
The problem is that I receive the Warning:
"REFERENCE MADE TO UNRESOLVED EXTERNAL", which means that the cpompiler does not find the code.

I use the registers R4 to R7 to receive the long int value and R3 and R2 to save the address.
Can anyone explain what I doing wrongly?
Thanks.
Amilcar

Here is the code:

; **********************************************************************
; function: iap_program_data_byte
; prototype: unsigned char iap_program_data_byte(unsigned char val, unsigned int addr);
; description: programs a dword in the flash. passed is the byte and the
; 16-bit address. zero is returned for success, non zero is returned for
; failiure.
; **********************************************************************
RSEG ?PR?_iap_program_data_dword?IAP
_iap_program_data_dword:
PUSH IE ; disable interrupts
CLR EA
MOV A,CMOD
MOV R2,A ; store copy of CMOD
JNB ACC.6,?IAPTWDOG ; if watchdog enabled then disable
ANL CMOD,#0BFH
?IAPTWDOG:
ORL AUXR1,#020H ; enable bootrom
MOV R0,iap_freq ; osc frequency
MOV R1,#02H

MOV DPH,R2 ; address to program
MOV DPL,R3

MOV A ,R4 ; data to write
CALL 0FFF0H ; call iap routine
MOV R7,A ; id in accumulator

INC DPTR
MOV A,R5 ; data to write
CALL 0FFF0H ; call iap routine
MOV R7,A ; id in accumulator

INC DPTR
MOV A,R6 ; data to write
CALL 0FFF0H ; call iap routine
MOV R7,A ; id in accumulator

INC DPTR
MOV A ,R7 ; data to write
CALL 0FFF0H ; call iap routine
MOV R7,A ; id in accumulator

ANL AUXR1,#0DFH ; disable bootrom
MOV CMOD,R2 ; restore CMOD (restore watchdog state)
POP IE ; restore interrupts to initial state
RET
; end of iap_program_data_dword

Parents
  • void main(void)
    {

    com_config_timer1();
    com_config_serialIO();
    com_baudrate (4800);

    sys_ini();

    while(1)
    {
    while (status != MEM_FREE)
    {
    printf("Memoria ocupada!, Vou passar p o proximo endereco\n");
    addr = addr + INCREM;
    }//if

    status = iap_read_data_byte(addr); }// while (status != MEM_LIVRE)

    iap_program_data_dword(longitude, addr); //armazena
    if (status == 1) printf("Programming sucess!...\n");
    }

Reply
  • void main(void)
    {

    com_config_timer1();
    com_config_serialIO();
    com_baudrate (4800);

    sys_ini();

    while(1)
    {
    while (status != MEM_FREE)
    {
    printf("Memoria ocupada!, Vou passar p o proximo endereco\n");
    addr = addr + INCREM;
    }//if

    status = iap_read_data_byte(addr); }// while (status != MEM_LIVRE)

    iap_program_data_dword(longitude, addr); //armazena
    if (status == 1) printf("Programming sucess!...\n");
    }

Children