CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

SFR with multiple addresses

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lvecch01



Joined: 19 Apr 2017
Posts: 3

View user's profile Send private message

SFR with multiple addresses
PostPosted: Wed Apr 19, 2017 2:52 pm     Reply with quote

Hello, I am a beginner in the microcontroller world and the following is breaking my head. I am using a 16F648A. For some Special Function Registers, this PIC has more than one address. PORTB address is 06h and 106h, INTCON address is 0Bh, 8Bh, 10Bh, 18Bh. So, at the beginning of the program where I put: #byte INTCON=0x??? which address should I put???

Thanks in advance to anybody can help me on it.
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Wed Apr 19, 2017 4:56 pm     Reply with quote

Don't worry about accessing the registers directly.

Let the compiler so all the work.
_________________
Google and Forum Search are some of your best tools!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 19, 2017 5:00 pm     Reply with quote

They are given multiple addresses so the programmer can access them
without switching the RAM bank. It's done so the program won't have
to switch banks as much and can therefore run faster.

Just use the first address.

Also, you don't have to type them in if you have the IDE version of the
CCS compiler. The compiler will make a file for you, with all register
addresses. You can just #include it in your program. This thread has
instructions on how to do it.
http://www.ccsinfo.com/forum/viewtopic.php?t=52602
lvecch01



Joined: 19 Apr 2017
Posts: 3

View user's profile Send private message

PostPosted: Wed Apr 19, 2017 6:14 pm     Reply with quote

Thanks PCM, I did what you say and nothing seems to happen. If I delete the #byte OPTION=0X81 instruction, then when it try to compile bit_set(OPTION,0); it says me Undifined Identifier OPTION.

In this case, I am setting the WDT time by setting and clearing bits in the OPTION register. So, you says I can do it in any address assigned for this SFR and the effect will be the same? How the controller knows what address to use? What if I put different values in different addresses?

Thanks
Luciano
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 19, 2017 6:26 pm     Reply with quote

While your project is open, press F11, and the CCS manual will open up....
simple search for setup_wdt(). You'll find that CCS has an EASY way to setup the WDT.

You should read the manaul as it has all sorts of nice, simple, reliable ways to use 'C' to control PICs...


Jay
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Wed Apr 19, 2017 6:33 pm     Reply with quote

If you're set on doing things the hard way, look up "getenv" in the help documentation. You can also search the forum for "getenv".
lvecch01



Joined: 19 Apr 2017
Posts: 3

View user's profile Send private message

PostPosted: Thu Apr 20, 2017 4:00 pm     Reply with quote

Ok, I solved the problem using the help and putting the statement #FUSES WDT and SETUP_WDT(576ms). Before of that I missed the #FUSES and it didn't work, thats why I took the hard way, setting and clearing bits in the SFR.

Thanks to all.
Luciano.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group