![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Hi This is the first time I reach about 550 instruction set in 16F877 But it started causing troubles My code is about several subroutines called from the main program At the beginning of the project I was adding the code piece after piece And make a test after adding every sub routine (all the subroutines are working well individually) But when added the last piece of code it dose not work When moving it after the main program It works but leaving the last piece of code not working! I thing it's a matter of paging the program memory I do not know how to deal with PCLATH register and my whole program will not exceed 700 instruction set any help?
__________________ I’m from Syrian Arab Republic where lots of guys are trying to do better in electronics. | |
| |
| | (permalink) |
| If your code is not going to exceed 700 instructions then it will fit in one bank. The bank size if 2048 (0x800) instructions. It is more likely that a table is moving and crossing a page boundary. Look for any access to PCL and check that the table that follows is all in one page - IE has the same high byte in the address. If your code is going over 2k then you can call subroutines in the far bank by doing the following, Code: movlw high(FarSub) movwf PCLATH call FarSub clrf PCLATH Code: bsf PCLATH,3 call FarSub bcf PCLATH,3 Mike. | |
| |
| | (permalink) |
| There's also a Microchip macro 'fcall', which generates the required code for you: Code: ; Macros
fcall macro subroutine_name
local here
lcall subroutine_name
pagesel here
here:
endm | |
| |
| | (permalink) |
| This is one of the reasons I decided not to use PIC's, pageing is a pain.
__________________ "Because I be what I be. I would tell you what you want to know if I could, mum, but I be a cat, and no cat anywhere ever gave anyone a straight answer, har har." | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| I put all the subroutines which contain tables in the beginning of the program memory and the problem is solved thanks guys
__________________ I’m from Syrian Arab Republic where lots of guys are trying to do better in electronics. | |
| |
| | (permalink) | |
| Quote:
If anything, with the release of 24F and dsPIC's, the 18F's should be the new mid-range devices
__________________ Spency. PIC Micro's - Your mind is the limit PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net | ||
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Is the 16F917 the successor to the 16F877? | William At MyBlueRoom | Micro Controllers | 5 | 26th September 2006 04:55 PM |
| Urgent Pic 16f877 | akk182 | Micro Controllers | 8 | 25th July 2006 10:39 PM |
| programming 16F877 in C for voice controlled robot | antoni1 | Micro Controllers | 2 | 24th September 2004 04:28 AM |
| Newbie HELP Strange happenings 16f877 | Lynny | Micro Controllers | 4 | 5th August 2003 10:01 PM |
| 16f877 help with config word | fishcurry | Micro Controllers | 1 | 31st July 2003 12:02 PM |