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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/30/07 18:17
Read: times


 
#148852 - P89V51RD2 IAP
Responding to: ???'s previous message
Nishant Agrawal said:
1.Can we write the IAP rotuines completely in C or do we need to use some part of assembly?

The short answer is no.

The long answer is maybe, but then you'd use such extensions of the compiler which are not C anyway.

The IAP call routine should:
1. be located absolutely above the fist 8kB (that you apparently know)
2. be tolerant against change of a couple of registers - I don't remember by heart but I've written explicitly which in a post in this forum already - please search; so you either have to make sure changing these won't upset the compiler or store them explicitly before making the call
3. swap bottom flash to the boot block(writing to the appropriate SFR)
3a. disable interrupts if any enabled and make all measures relevant to this topic (e.g. you might want to wait until a timer interrupt occurs to make sure you won't miss any while disabled etc.)
4. call an absolute address (1FF0h)
5. cleanup: swap back to application flash, reenable interrupts, restore registers etc.

Nishant Agrawal said:
2.Do we need to leave the first 8 KB of code memory if we are to use the IAP calls?


No; in fact you can't - the code starts at address 0 anyway after reset...

Only the flash swap and call to 1FF0 and flash swapback needs to sit above 2000h.

Search around this Forum - this topic has been discussed several times already. You might get inspired.

JW



List of 4 messages in thread
TopicAuthorDate
P89V51RD2 IAP            01/01/70 00:00      
   P89V51RD2 IAP            01/01/70 00:00      
   why            01/01/70 00:00      
   P89v51 POR (Power On Reset)            01/01/70 00:00      

Back to Subject List