![]() | ![]() | ![]() |
| | |||||||
| 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 I have a terrible problem when writing to PCLATH so please take a look. I attached the disassembly listing it shows the actual line number in my Data Tables. You can see the half of Table11 & Table12 exceeding 0FFh mark. Highlighted in red. I can call Table1 to 10 anywhere in the program memory. Because there in the first 0FFh mark. But when I call Tables 11 & 12 it won’t work very well. I’m calling Table11 from 12Fh line. Here what I wrote to PCLATH. Code: calling Table11 from 12Fh line
movlw HIGH Table11
movwf PCLATH
call Table11 | |
| |
| | (permalink) |
| Have you tried running it through MPLABs simulator. Should be easy to spot what's happening then. Also try looking into the fcall macro Code: fcall macro subroutine_name
local here
lcall subroutine_name
pagesel here
here:
endm Last edited by blueroomelectronics; 17th September 2007 at 04:22 AM. | |
| |
| | (permalink) | |
| Quote:
But when I reduced the data in the Table11 its working because its below first 0FFh mark. And I dont know anything about macros. | ||
| |
| | (permalink) |
| Hi, I think your table 12 should be working well. Look at the table 11, it starts at memory location 0x00EC and ends at 0x010A. So you are able to call table 11 until 0x00ff. From 0x0100 onwards, it starts going wrong because the high side of table 11 is always 0x00. Do you get what I mean? You can force the high side of table 11 to start at 0x01 by: Code: org 0x0100 table11 addwf PCL, f . .
__________________ Superman returns.. | |
| |
| | (permalink) | |
| Quote:
I’ll add org 0X0100 to Table11 as you mentioned Code: org 0x0100 Table11 addwf PCL,F retle xx Code: movlw HIGH Table11
movwf PCLATH
call Table11 Tell me am I right? | ||
| |
| | (permalink) |
| Using the sim is simply selecting it from the debug menu. Add view watchlists like PCL and PCLATH and single step through your program. | |
| |
| | (permalink) |
| Yes you're right. Because PCL is an 8-bit register. As long as the high side of the table doesn't change in the table, then everything will be fine.
__________________ Superman returns.. | |
| |
| | (permalink) |
| Thanks a lot bananasiong then for the Table12 I wont need an org statement. I can call directly like this from anywhere in the program memory. Code: movlw HIGH Table12
movwf PCLATH
call Table12 | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| If you calculate the address properly then you can have your tables anywhere you like. Code: TableNN movwf Temp ;Save W movlw High TabNN ;get high byte of address movwf PCLATH ;put in PCLATH movlw Low TabNN ;get low byte addwf Temp,W ;add on offset btfsc STATUS,C ;crossed page boundary? incf PCLATH,F ;yes, so increment high byte movwf PCL ;do jump TabNN dt "Hello World",0 Last edited by Pommie; 17th September 2007 at 06:01 AM. Reason: Clarification | |
| |
| | (permalink) |
| Hi Mike you are always there. Oh I see another method.So I can place the Tables anywhere in the program memory. In your method do I need to add org statements for Tables?Or without org statements I can place Tables anywhere? Thanks. | |
| |
| | (permalink) |
| You can place tables anywhere, even if they cross a page boundary it will still work correctly. Mike. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| Besides the giving of fish, good to also train how to fish. AN556 http://ww1.microchip.com/downloads/e...tes/00556e.pdf AN's - The great solvers of mystery. | |
| |
| | (permalink) |
| Anyone into PIC programming should really take time to fully understand the purpose and significance of PCLATH. One would need to take care of it during Table read crossing 256 page boundary, CALL/GOTO code crossing 2K boundary and possibly interrupt handling.
__________________ L.Chung | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Validating Code Without PIC | burg | Micro Controllers | 4 | 22nd April 2007 05:14 PM |
| Accessing EEPROM | Clayton | Micro Controllers | 15 | 23rd March 2007 04:00 AM |
| Pic16f88 | Mark (Imagine Design) | Micro Controllers | 5 | 6th June 2006 10:21 PM |
| Code not working..help | Electrix | Micro Controllers | 15 | 26th September 2005 12:12 PM |
| PCLATH | heida11 | Micro Controllers | 2 | 19th December 2004 01:15 PM |