| Electronic Components Datasheet Search |
|
AN247 Datasheet(PDF) 6 Page - Microchip Technology |
|
|
|||||||||||||||||||||||||||||
AN247 Datasheet(HTML) 6 Page - Microchip Technology |
|
6 / 32 page ![]() AN247 DS00247A-page 6 2003 Microchip Technology Inc. It is also important to note some configuration bits are single direction bits in Normal mode; they can only be changed to one state, and cannot be changed back. The code protection bits in Configuration registers 5L and 5H are a good example. If any type of code protec- tion is enabled for a block, it cannot be disabled without a device programmer. Essentially, the bootloader cannot reverse code protection. The Device ID (addresses 3FFFFEh and 3FFFFFh) is also considered Program Memory. While they can be accessed, however, they are read only and cannot be altered. Write Latency When writing data, there is a specific time that the pro- gramming source must wait for to complete the pro- gramming operation. Fortunately, the CAN module actually buffers received data; therefore, receiving can actually overlap memory write operations (Figure 6). In general, it takes about 2 ms for Program Memory write operations, while EEDATA takes about 4 ms. Not all PIC18F devices have the same time specifications, so it is important to verify the write times for the specific device to be used. FIGURE 6: CAN RECEIVE VS. MEMORY WRITE WRITING CODE The bootloader operates as a separate entity, which means that an application can be developed with very little concern about what the bootloader is doing. This is as it should be; the bootloader should be dormant code until an event initiates a boot operation. Under ideal circumstances, bootloader code should never be running during an application’s intended normal operation. When developing an application with a resident bootloader, some basic principles must be kept in mind. Writing in Assembly When writing in assembly, the boot block and new vec- tors must be considered. For modular code, this is gen- erally just a matter of changing the linker script file for the project. An example is given in Appendix C. If an absolute address is assigned to a code section, the address must point somewhere above the boot block. For those who write absolute assembly, all that is nec- essary to remember is that the new RESET vector is at 200h, and the interrupt vectors are at 208h and 218h. No code except the bootloader should reside in the boot block. Writing in C When using the MPLAB® C18 C compiler to develop PIC18F firmware for an application, the standard start-up object (c018.o or c018i.o) must be rebuilt with the new RESET vector. Like modular assembly, the linker file must be changed to incorporate the pro- tected boot block and new vectors. Appendix C shows an example linker file. Users of other compilers should check with the com- piler’s software user guide to determine how to change the start-up code and vectors. Bootloader Re-Entry If the need exists to re-enter Boot mode from the appli- cation (and it usually does), the last location of the data EEPROM must be set to FFh. The code in Example 1 demonstrates how this might be done in an application. Since the bootloader assumes RESET conditions, a RESET instruction should be initiated after setting the last location. EXAMPLE 1: SETTING THE LAST LOCATION OF THE DATA MEMORY CAN Msg CAN Message Receive Memory Write SETF EEADR ; Point to the last byte SETF EEADRH SETF EEDATA ; Bootmode control byte MOVLW b'00000100 ; Setup for EEData MOVWF EECON1 MOVLW 0x55 ; Unlock MOVWF EECON2 MOVLW 0xAA MOVWF EECON2 BSF EECON1, WR ; Start the write NOP BTFSC EECON1, WR ; Wait BRA $ - 2 RESET |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |