Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 29th April 2007, 10:45 PM   (permalink)
Question Help in paging 16F877

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.
TronicBrain is offline  
Old 30th April 2007, 01:10 AM   (permalink)
Default

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
Or,
Code:
		bsf	PCLATH,3
		call	FarSub
		bcf	PCLATH,3
Note that once you are in bank 2 then all calls and gotos will stay in bank 2 until you "return" to bank 1.

Mike.
Pommie is offline  
Old 30th April 2007, 09:41 AM   (permalink)
Default

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
To use it just add it to the header of your program and use fcall instead of call for your subroutines.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 1st May 2007, 01:47 AM   (permalink)
Default

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."
Sceadwian is offline  
Old 1st May 2007, 02:12 AM   (permalink)
Default

Quote:
Originally Posted by Sceadwian
This is one of the reasons I decided not to use PIC's, pageing is a pain.
So use the 18F series, very little paging.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Old 1st May 2007, 10:26 AM   (permalink)
Default

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.
TronicBrain is offline  
Old 2nd May 2007, 03:16 PM   (permalink)
Default

Quote:
Originally Posted by blueroomelectronics
So use the 18F series, very little paging.
18F's are easier to use at the end of the day. 16F's are so old school now.

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
gramo is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
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



All times are GMT. The time now is 09:51 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker