I am using the P89C51RD+ from Philips. I intend to use the flash as follows: 0x000- 0x1FFF to save the program code.This prohram acquires data from a GPS, processes it and saves it. 0x2000- 0xFFFF : the processed data ust be saved in this space in the Flash memory. Is it possible? How should I do it? I have tried to use the IAP to save the data to the flsh but I dont have a mean to prove that it works. Here are the routines in assembly: NAME IAPMODE ; PUBLIC _COPIA_P_FLASH, _APAGAR_FLASH, _LE_D_FLASH IAP_ROUTINES SEGMENT CODE ;Declaração de Variáveis AUXR1 DATA 000A2H PGM_MPT EQU 0FFF0H ;Philips FirmWare RSEG IAP_ROUTINES /*****************************************************************************/ /* +Funcao : carregar(long,u16) */ /* +Descrição : rotina que invoca uma rotina, 'In Aplication Program (IAP) */ /* do micro para a escrita de um byte */ /* */ /*****************************************************************************/ _COPIA_P_FLASH: MOV AUXR1,#20H ;Carregamento de dados na Flash MOV R0,#11 ;frequencia do micro MOV R1,#02H MOV A,R3 MOV DPH,R7 ;parte alta MOV DPL,R5 ;parte baixa CALL PGM_MPT RET /* FIM de _LOAD */ /*****************************************************************************/ /* +Funcao : apagar(char) */ /* +Descrição : rotina que invoca uma In Aplication Program (IAP) do micro */ /* para apagar blocos na memoria */ /* */ /*****************************************************************************/ _APAGAR_FLASH: MOV AUXR1,#20H ;Apaga blocos da Flash CLR A MOV DPL,A MOV R0, #32 MOV R1, #01 MOV DPH,R7 CALL PGM_MPT RET /* FIM de _APAGAR */ /*****************************************************************************/ /* +Funcao : ler(char, char) */ /* +Descrição : rotina que invoca uma In Aplication Program (IAP) do micro */ /* para apagar blocos na memoria */ /* */ /*****************************************************************************/ _LE_D_FLASH: MOV AUXR1, #20H ;ENBOOT = 1 (required on some parts) MOV R1, #01H ;codigo da operacao de leitura MOV DPH, R6 MOV DPL, R7 ;o endereço e de 16bits,fica em R6&R7 CALL PGM_MPT MOV R7,A ; C51 expects return in R7 RET END I call those routines using C routines: extern byte apagar_flash(unsigned char); extern byte copia_p_flash(char,char, char); extern byte le_d_flash(u16 addr); I am using the keil Uvision v2.33 Am I doind the right way? I cant put the program to work when I save the code in the micro! Is there any way to download the program and test it directly from the Uvision2? I ask this beacuse there's a tab that permits to download but I ca't get access to that. Thanks.
I made those routines based on a aplication note. Le_D_Flash is the same then READ_FROM_FLASH, COPIA_P_FLASH is for COPY_TO_FLASH and APAGAR... is for ERASE_BLOCK.I am sorry for the inconvinence.The comments are writen i portuguese. My problem is that when I try to use this functions to save data in the Flash the program does not run! But if I take this functions off it works. The difference between RAM and FLASH is that in RAM the data is lost when the power in turned off.In the Flash the proceudre to save is slower but is never lost when power is turned off. The link you gave has 3 functions that are alike the ones I am using but it is still useful, I am working on it.Thanks.
I have found the functions that you mentioned.I am running the example but there is no sign that its working.Do you know how to use the monitor51?