Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

whats this:

Status
Not open for further replies.

Thunderchild

New Member
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF


this came from the 16F88 template ASM file I canmnot find any mention of these things in the datasheet or the midrange general guide or anywhere this is the one thing that has me stomped do I need worry about this lot or just use a certain string every time ?

understanding assembly code is not too hard but trying to make out something there is virtually no explanation for is impossible
 
hi,
Look at pages 130 and 131 of the 16F88 datasheet for a description of the
CONFIGURATION word.:)
 
Last edited:
I'm also new in microcontroller world. I've been reading lots of infos from this forum also. But I guess these things might answer your questions. I hope so.:)
Code:
[B]Directives [/B]

A directive is similar to an instruction, but unlike an instruction it is independent on the microcontroller model, and represents a characteristic of the assembly language itself. Directives are usually given purposeful meanings via variables or registers. For example, LEVEL can be a designation for a variable in RAM memory at address 0Dh. In this way, the variable at that address can be accessed via LEVEL designation. This is far easier for a programmer to understand than for him to try to remember address 0Dh contains information about LEVEL. 
 
[B]3.3 Writing a sample program [/B]
The following example illustrates a simple program written in assembly language respecting the basic rules. 

When writing a program, beside mandatory rules, there are also some rules that are not written down but need to be followed. One of them is to write the name of the program at the beginning, what the program does, its version, date when it was written, type of microcontroller it was written for, and the programmer's name. 
 
Since this data isn't important for the assembly translator, it is written as comments. It should be noted that a comment always begins with a semicolon and it can be placed in a new row or it can follow an instruction. 
After the opening comment has been written, the directive must be included. This is shown in the example above.

In order to function properly, we must define several microcontroller parameters such as:  - type of oscillator,
- whether watchdog timer is turned on, and
- whether internal reset circuit is enabled.
All this is defined by the following directive:

_CONFIG _CP_OFF&_WDT_OFF&PWRTE_ON&XT_OSC

When all the needed elements have been defined, we can start writing a program.
First, it is necessary to determine an address from which the microcontroller starts, following a power supply start-up. This is (org 0x00).
The address from which the program starts if an interrupt occurs is (org 0x04).
Since this is a simple program, it will be enough to direct the microcontroller to the beginning of a program with a "goto Main" instruction. 

The instructions found in the Main  select memory bank1 (BANK1) in order to access TRISB register, so that port B can be declared as an output (movlw 0x00, movwf TRISB). 

The next step is to select memory bank 0 and place status of logic one on port B (movlw 0xFF, movwf PORTB), and thus the main program is finished.
We need to make another loop where the micro will be held so it doesn't "wander" if an error occurs. For that purpose, one infinite loop is made where the micro is retained while power is connected. The necessary "end" at the end of each program informs the assembly translator that no more instructions are in the program.
And here are some description:
Code:
3.21 _CONFIG         Setting the configurational bits 

Syntax:
_ _config<term> or_ _config<address>,<term> 

Description:
Oscillator, watchdog timer application and internal reset circuit are defined. Before using this directive, the processor must be defined using PROCESSOR directive. 

Example:
_CONFIG _CP_OFF&_WDT_OFF&_PWRTE_ON&_XT_OSC

Similar directives: _IDLOCS, PROCESSOR
 
yes i get the gist but there are no precide instructions on what I'm doing where can i get information that says "to de/activate this function use "this" directive, are they essential I mean alternatively can i just write to the various registers to implement what I'm doing with the pic
 
These are configuration values and have little to do with the processor registers. They are used to determine the value for configuration byte(s) aka FUSES that are read by the processor prior to executing any code you may program it with.

You tell the compiler or assembler what value to use for the FUSES and when you flash the chip the FUSE memory will be set accordingly. You can not change them from inside a running program.
 
Last edited:
ok so you mean pages 130-131 so it talks about bits and if its "0" it does such and such and if "1" it does such and such, it doesen't explain what "strings" I have to write
 
isn't it a bit stupid of microchip to make things so hard ? they reckon its simple i do this as a past time at the moment and I'm seeming to waste a lot of time because of lack of clarity in information are pics really so great ?
 
where are they ? look the info on the datasheet seems to hardly relate to what is done in the real world so whats the game ? whats the point of the datasheet if its an endless list of well "specs" and has not much practical value ?
 
You question has been answered. :) But I will try again.

The assembler does the work for you.

if I use this line it will set the configuration mem with the coresponding values when I program the chip.
_CONFIG _CP_OFF&_WDT_OFF&PWRTE_ON&XT_OSC

If I want the same but with the watch dog timer on I would write
_CONFIG _CP_OFF&_WDT_ON&PWRTE_ON&XT_OSC

It is as simple as that. The & is a bitwise rather then a logical AND. So 0x01 & 0x40 = 0x41. the 40 will turn one thing on the 01 another, that sort of thing.
 
ok so I've found the directives explanations in MPLAB erm there is a ton how do I know which ones I'm using ? I presume the ones in the 16F88 templeate file has them all so if I check out their meaning I'll be ok... this is very confusing whats wrong with just listing the registers and saying "0" or "1"

for example CP="0"
 
ok so I've found the directives explanations in MPLAB erm there is a ton how do I know which ones I'm using ? I presume the ones in the 16F88 templeate file has them all so if I check out their meaning I'll be ok... this is very confusing whats wrong with just listing the registers and saying "0" or "1"

for example CP="0"

hi TC,
Chill, its always con 'fusing' at first.:)

The word fuse is a hang over from the time ic's did have an internal 'minifuse link' which was actually 'blown'
or not during programming,, I never use it, its confusing to new readers.

The assembler expects the program writer to define the CONFIGURATION, on how the PIC's
'internal hardware' is going to be used.

A simple one is the FOSC <2:0> a three bit code, it tells the PIC which oscillator configuration you are using..
eg internal or external.

Another one is the WDTEN, watch dog timer.
This is used with your program so that if the WDT times out, something is 'wrong' in the programs operation
and so your program has to take corrective action.
I dont normally use it, so I switch it OFF.

/PWRTEN, Power up Timer enable.
This is a delay on starting the actual program after the power has been switched ON, gives the osc time to settle.
I use it as it gives the LCD a little time to settle.

MCLRE, This is to use the RA5 pin either as a RESET pin OR a digital pin.

BOREN, Do you want to check for a 'dip' in the Vss to the PIC. a brown out.
If brown out is used, then your program could be written to give a warm start. etc.


Does this help a little.?
 
Last edited:
yes that certainly helps eric thanks I think my myke predko pic book has a simplified explanation as well so I'll delve into that (hoping he didn't make mistakes on that bit of the book)
 
The easiest way to start is to search the web for programs that do what you want to do (or more or less what you want to do), look what fuses they used, and look up why they did it, then change the fuses that you need.

yea and i went and picked the 16F88 (was just a personal recomendation of a fellow electro-tech-online member) but I never ever see any examples with it its like it never existed i downloaded the template files the other day and it was not even in it ! I eventually retreived it from MPLAB
 
yea and i went and picked the 16F88 (was just a personal recomendation of a fellow electro-tech-online member) but I never ever see any examples with it its like it never existed i downloaded the template files the other day and it was not even in it ! I eventually retreived it from MPLAB

If you look around you should see a few PICs that are pin compatible with yours, so when searching for code you can also search for those model numbers.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top