All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Embedded Systems and Microcontrollers

Notices

Embedded Systems and Microcontrollers Discussion forum for projects and working with embedded systems and microcontrollers (FPGAs, PICs, AVRs). Get help with hardware issues and embedded programming.

Reply   Post New Thread
 
Thread Tools Display Modes
  #1  
Old 02-25-2010, 12:28 AM
campeck campeck is online now
Member
 
Join Date: Sep 2009
Posts: 90
Default Configuration word register questions

Hey
The target device is a 12F683

#include <p12F683.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF)



I am going through some tutorials and this is at the top of the program.
What's going on here? Am I turning things off or on? Are these defaults?

Also to set the internal oscillator to 8Mhz bit 4,5 and 6 of the OSCCON register need to be set to 1.

so why does this tutorial tell me to use 0x70 which isn't that 112? Wouldn't I use 0x6F? and put that into OSCCON?

Thankyou.
Reply With Quote
  #2  
Old 02-25-2010, 12:32 AM
campeck campeck is online now
Member
 
Join Date: Sep 2009
Posts: 90
Default

Hmm. Is all I am doing is adding those presets to the config at the beginning of the program? So By adding the _WDT_OFF to the config I am just presetting the Watchdog to be off? What would happen If I left it out?
Reply With Quote
  #3  
Old 02-25-2010, 12:16 PM
Markd77's Avatar
Markd77 Markd77 is offline
Senior Member
 
Join Date: Sep 2009
Location: Birmingham
Posts: 689
Default

Have a look at this and see if answers your questions.
http://forum.allaboutcircuits.com/sh...ad.php?t=32986
As for OSCCON, 0x70 would be 01110000, 0x6F would be 01101111 so 0x70 would be the correct choice.
I'm not sure what happens if you leave out parts of the config word. Probably best to define them.
Reply With Quote
  #4  
Old 02-26-2010, 02:22 AM
n9352527 n9352527 is offline
Senior Member
 
Join Date: Oct 2005
Posts: 1,198
Default

Notice that each config value are & (bitwise and-ed) together. So, a particular config value is defined as a mask with the corresponding bit set to zero. Leaving a config value will have no effect, if the default bit value of 1 is what you want (in other words, most of the configured peripherals will be on). Otherwise, the config value will have to be defined.
Reply With Quote
  #5  
Old 02-26-2010, 04:22 AM
campeck campeck is online now
Member
 
Join Date: Sep 2009
Posts: 90
Default

So I can say this? I can label them on or off I mean...

_WDT_ON & _MCLRE_ON ?
Reply With Quote
  #6  
Old 02-26-2010, 08:22 AM
n9352527 n9352527 is offline
Senior Member
 
Join Date: Oct 2005
Posts: 1,198
Default

I don't think all the _XXX_ON labels are defined, but you better check on the datasheet first (or see in the include file). To set the peripherals to on, you leave out the particular config label. Notice that the /CPD, /CP and /PWRTE are inverted (on when the bit value is 0). The default settings then would be OFF, there must be a _XXX_ON labels to set those settings on, otherwise including either one of them (like _CP_OFF) would mean setting all three of them off (notice that they have the same hex value settings).

Last edited by n9352527; 02-26-2010 at 08:38 AM.
Reply With Quote
  #7  
Old 02-26-2010, 08:26 AM
Tahmid's Avatar
Tahmid Tahmid is offline
Senior Member
 
Join Date: Jul 2008
Location: Dhaka
Posts: 265
Default

Don't leave WDT on, it'll pose problems unless you really intend to use them (which I assume you don't since you're just starting new). So keep _WDT_OFF. For MCLRE, that's Master Clear Enable. If this is on, you need to pull the pin "Master Clear" which I think is pin 1, high. When this pin is low, the microcontroller is in reset mode, where it goes to reset vector. Keeping this pin low means no execution of code. If you keep MCLRE off, then you won't have this feature and you won't need the external resistor.
So it should be _WDT_OFF & _MCLRE_OFF (you could keep master clear on, but not WDT).

Hope this helps.
Tahmid.
__________________
পৃথিবীর সর্বোচ্চ দালানও প্রথম ইট বসানো থেকেই তৈরি হয়েছে।
The tallest building in the world starts from the first brick.
Reply With Quote
  #8  
Old 02-26-2010, 10:26 AM
Alberto Alberto is offline
Senior Member
 
Join Date: Nov 2008
Posts: 876
Default

Quote:
.... If you keep MCLRE off, then you won't have this feature and you won't need the external resistor.
Tahmid, let me correct your statement, just for the sake of precision: If you don't use the pin as MCLR then the pin is an INPUT PIN by default and it is not wise to leave an input floating! So if the pin is not used and MCLR is off then the pin should be either pulled down or up.

Alberto
Reply With Quote
  #9  
Old 02-26-2010, 10:58 PM
campeck campeck is online now
Member
 
Join Date: Sep 2009
Posts: 90
Default

Quote:
Originally Posted by n9352527 View Post
I don't think all the _XXX_ON labels are defined, but you better check on the datasheet first (or see in the include file). To set the peripherals to on, you leave out the particular config label. Notice that the /CPD, /CP and /PWRTE are inverted (on when the bit value is 0). The default settings then would be OFF, there must be a _XXX_ON labels to set those settings on, otherwise including either one of them (like _CP_OFF) would mean setting all three of them off (notice that they have the same hex value settings).
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF)

So I could shorten that to...

__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _IESO_OFF & _FCMEN_OFF)

no _CP_OFF?

Quote:
Originally Posted by Alberto View Post
Tahmid, let me correct your statement, just for the sake of precision: If you don't use the pin as MCLR then the pin is an INPUT PIN by default and it is not wise to leave an input floating! So if the pin is not used and MCLR is off then the pin should be either pulled down or up.

Alberto
And they are high impedance when inputs right? So can I connect straight to Vss or Vdd?

Last edited by campeck; 02-27-2010 at 03:31 AM.
Reply With Quote
  #10  
Old 02-27-2010, 08:22 AM
Alberto Alberto is offline
Senior Member
 
Join Date: Nov 2008
Posts: 876
Default

Quote:
...And they are high impedance when inputs right? So can I connect straight to Vss or Vdd?
Yes. But it is wiser to use a pullup or pulldown resistor.

Alberto
Reply With Quote
Reply   Post New Thread

Bookmarks

Tags
, , ,

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
decoder and register in Verilog notwist Programmer's Corner 1 11-22-2007 04:44 PM
Help in ports configuration FZA Programmer's Corner 12 08-07-2007 03:16 AM
Ask questions instead of give answers terrytapp Homework Help 6 10-29-2006 01:15 PM


All times are GMT. The time now is 10:20 PM.


User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License. Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.