![]() |
|
|||||||
| 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. |
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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?
|
|
#3
|
||||
|
||||
|
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. |
|
#4
|
|||
|
|||
|
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.
|
|
#5
|
|||
|
|||
|
So I can say this? I can label them on or off I mean...
_WDT_ON & _MCLRE_ON ? |
|
#6
|
|||
|
|||
|
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. |
|
#7
|
||||
|
||||
|
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. |
|
#8
|
|||
|
|||
|
Quote:
Alberto |
|
#9
|
|||
|
|||
|
Quote:
So I could shorten that to... __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _IESO_OFF & _FCMEN_OFF) no _CP_OFF? Quote:
Last edited by campeck; 02-27-2010 at 03:31 AM. |
|
#10
|
|||
|
|||
|
Quote:
Alberto |
|
| Bookmarks |
| Tags |
| configuration, questions, register, word |
| Thread Tools | |
| Display Modes | |
|
|
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 |