PDA

View Full Version : Configuration fuses in source file for 18f252



PickyBiker
- 22nd March 2010, 03:21
I have been struggling for a while now trying to set the config fuses I need in the source code of an 18f252 project.

What I need is:

HS Osc
mclr disabled
wdt disabled

I am using mpasmwin, but I just don't seem to get the includes and syntax right.

An example would be great.

Thanks,

Mike

mackrackit
- 22nd March 2010, 04:06
This thread is a good read
http://www.picbasic.co.uk/forum/showthread.php?t=543

For an example the best place to look will be in the file the above thread speaks about. The inc file for the chip you are using in the PBP directory.

To find all of the options for the chip go to - program files - micro chip - mpasm suite and find the inc file there for your chip. Do not change anything in this one. Look near the end of the file for all of the config options.

PickyBiker
- 22nd March 2010, 04:18
I believe I have already done all of that. I found out about needing mpasm. I found the include file for the 18f252 and I copied the config statement near the bottom into the source file. It gives me a syntax error every time.

Do I need to copy the .inc file into the project?

I really need to see a sample code section to see exactly how it is supposed to look inside the PBP .bas file.

Thanks,

Mike

mackrackit
- 22nd March 2010, 04:28
Can we see your code?

You do not copy the whole file, just the config lines.
Might be better at this point to not set the fuses in code. Just modify the PBP inc file.

PickyBiker
- 22nd March 2010, 04:35
' using 20 MHz Resonator Pause 1 = 200 usec, 10 = 2 msec

__CONFIG _CONFIG1H, _HS_OSC_1H

symbol LED = 0 'Rename pin 0 of portb (PIC 16F84 pin 6) to LED

trisb = %00000001 'Setup port b as RB7-RB1 inputs, RB0 as output

main: 'Label for beginning of main loop
High LED 'Set pin 0 of portb high (5 volts) which turns the LED on
pause 10 'Pause 2 milliseconds with LED on
Low LED 'Set pin 0 of portb low (0 volts) which turns the LED off
pause 90 'Pause for 18 milliseconds with LED off
goto main 'Jump to the main label and do it all again and again

mackrackit
- 22nd March 2010, 04:45
@ __CONFIG _CONFIG1H, _HS_OSC_1H

try that

mackrackit
- 22nd March 2010, 04:48
And if you add
DEFINE OSC 20
near the beginning of your code you will not have to recalc the pauses

PAUSE 1000
will be 1 second

PickyBiker
- 22nd March 2010, 05:37
Now that is progress.

DEFINE OSC 20, is a very nice little bit of info.

and

@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H

Did the trick.

I noticed that I can comment out the config lines in the 18f252.inc file in the c:\pbp folder and put them directly in the source, or make the changes in the .inc file directly.

I woud rather make a copy of the .inc file and put it in the project folder to make the changes there, but when I did that, it took the values from the original .inc file in the c:\pbp.

How can I tell it to use the modified copy in the project folder?

Thanks,

Mike

mackrackit
- 22nd March 2010, 05:45
The compiler will read the inc file, will always read the inc file. That is why you have to comment the things in the inc that you do not want read.

I know what you are after by making a copy of the inc for the project directory. But that would take some messing with the heart of PBP.. So that is why we have the way of putting the config settings in the code.

I guess you code write an include file for the configs... but then you would have the include statement in your code... Just stick with the configs in code space. It works.. :)

PickyBiker
- 22nd March 2010, 05:49
Okay... I can live with that.

I'll work with direct ,inc changes and putting the changes in the code and see which way works best for me.

Thank you al for the excellent help.

I will create a new post with my accomplishments so far, thanks to your help.

mackrackit
- 22nd March 2010, 05:52
For me, some chips I almost never change the fuses so I will modify the inc and leave it at that. Some chips get the fuses changed often, for those I will set them in code space.

Just thoughts...