There are two 2K word pages of program memory in the PIC16C74A. Program memory 000h to 7FFh is page 0, 800h to FFFh is page 1. By making fpm32() a C function, MPLAB-C initializes the appropriate page bit in the PCLATH register before the subroutine call is made. (See data sheet for more on PCLATH). A potential problem could arise, however, if the new C function, fpm32(), crosses the page boundary (7FFh,800h). MPLAB-C does not insert code into the assembly code to initialize the page bits (remember MPLAB-C does take care of paging for function calls). That means it is up to the programmer to either; 1) add assembly language to initialize PCLATH appropriately, or 2) move the entire #asm function within a single page. Option 1 involves more work. The programmer must first compile the C code, then analyze the listing file to see if the assembly function crossed a page boundary. Finally, add the appropriate assembly language to initialize PCLATH then re-compile. This solution is not desirable since every time new C code is added to or deleted from the program, the routine, fpm32() can potentially move across the page boundary. Option 2 is the simplest solution - to locate the C function in a single page. |