Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/03/05 16:37
Read: times


 
#96473 - My Code
Responding to: ???'s previous message
unsigned char __api_wr_code_page (word16 add_flash, word16 add_xram, unsigned char nb_data_lc) small
{
//bit ea_save;
byte save_auxr1,temp_lc,temp1_lc;
word16 temp_lw;

// ea_save = EA;

EA = 0;
save_auxr1 = AUXR1;

P2_0 = ~P2_0; // watch dog strobe

AUXR1 &= ~0x01; // Set DPTR0 to Destination Address

DPL = (byte)add_flash;
DPH = (byte)(add_flash >> 8);

AUXR1 |= 0x01; // Set DPTR Addr. to DPTR1

DPL = (byte)add_xram; // Set DPTR1 to Source Address
DPH = (byte)(add_xram >> 8);

temp_lc = (K_FPAGE_MAX - (add_flash %K_FPAGE_MAX));

while(nb_data_lc)
{
P2_0 = ~P2_0; //Watch Dog Strobe

if (nb_data_lc <temp_lc) // to test page boundary

temp_lc = nb_data_lc;

nb_data_lc -= temp_lc;

#pragma asm
MOV A,#0x09
MOV R1,A
#pragma endasm

ACC = temp_lc;

AUXR1 &= ~0x01; // Set DPTR = DPTR0

MAP_BOOT; // Set ENBOOT bit in AUXR1

API_Flash_Start(); // Jump to API calls (FFF0h)

if(nb_data_lc != 0)
{

AUXR1 &= ~0x01; // Set DPTR = DPTR0

temp_lw = add_flash + temp_lc;
DPL = (byte) temp_lw;
DPH = (byte)(temp_lw >> 8);

temp1_lc = (K_FPAGE_MAX - (temp_lw % K_FPAGE_MAX));

AUXR1 |= 0x01; // Switch DPTR0 to DPTR1

temp_lw = add_xram + temp_lc;
DPL = (byte)temp_lw;
DPH = (byte)(temp_lw >> 8);

temp_lc = temp1_lc;

}

UNMAP_BOOT;

}

AUXR1 = save_auxr1;
EA = 1; // restore interrupt state

return (ACC);
}


List of 42 messages in thread
TopicAuthorDate
IAP Problem in AT89C51RD2            01/01/70 00:00      
   IAP PROBLEM            01/01/70 00:00      
      misinterpretations            01/01/70 00:00      
   IAP source            01/01/70 00:00      
      IAP source?            01/01/70 00:00      
         ..xC51x.. IAP API            01/01/70 00:00      
            oh those...            01/01/70 00:00      
               IAP            01/01/70 00:00      
                  sorry...            01/01/70 00:00      
                  IAP            01/01/70 00:00      
               Yes, but..            01/01/70 00:00      
                  bootloader            01/01/70 00:00      
                     Depressing, isn't it?            01/01/70 00:00      
                        complaining to Atmel?            01/01/70 00:00      
                           please, WHAT is the problem            01/01/70 00:00      
                              Not at all...            01/01/70 00:00      
                                 comments            01/01/70 00:00      
                                    More comments            01/01/70 00:00      
                                       comments on more comments            01/01/70 00:00      
                                          other way 'round (a pinch of irony)            01/01/70 00:00      
                                             keep it going            01/01/70 00:00      
                                                What's the point?            01/01/70 00:00      
                                          COMCOMC            01/01/70 00:00      
                                             for those of you who need this            01/01/70 00:00      
                                                straighforward?            01/01/70 00:00      
   Interrupts            01/01/70 00:00      
      The coments are in spanish if you are in            01/01/70 00:00      
         Translation?            01/01/70 00:00      
            The code            01/01/70 00:00      
   IAP on Atmel            01/01/70 00:00      
      only 16 bytes?            01/01/70 00:00      
         don't know            01/01/70 00:00      
            that might be the explanation            01/01/70 00:00      
      Are you overwriting your own code? Where            01/01/70 00:00      
         code example            01/01/70 00:00      
            IAP Problem            01/01/70 00:00      
            My Code            01/01/70 00:00      
               This looks good...            01/01/70 00:00      
   Thank U for the Great support            01/01/70 00:00      
      I see many and no U            01/01/70 00:00      
      And what was the problem???            01/01/70 00:00      
         Not Yet            01/01/70 00:00      

Back to Subject List