View previous topic :: View next topic |
Author |
Message |
lvecch01
Joined: 19 Apr 2017 Posts: 3
|
SFR with multiple addresses |
Posted: Wed Apr 19, 2017 2:52 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Wed Apr 19, 2017 4:56 pm |
|
|
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!!!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Apr 19, 2017 5:00 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
lvecch01
Joined: 19 Apr 2017 Posts: 3
|
|
Posted: Wed Apr 19, 2017 6:14 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9177 Location: Greensville,Ontario
|
|
Posted: Wed Apr 19, 2017 6:26 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
newguy
Joined: 24 Jun 2004 Posts: 1903
|
|
Posted: Wed Apr 19, 2017 6:33 pm |
|
|
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". |
|
![](templates/subSilver/images/spacer.gif) |
lvecch01
Joined: 19 Apr 2017 Posts: 3
|
|
Posted: Thu Apr 20, 2017 4:00 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|