PDA

View Full Version : Trouble getting started



PickyBiker
- 25th October 2012, 18:57
Trying to compile a simple program for a PIC12F683 using PBP 3 in MPLAB. I am getting the following error:
Error[118] C:\USERS\MIKE\DESKTOP\STUFF\PROJECTS\GOLDWING TRUNK OPENER\GOLDWING TRUNK OPENER.ASM 139 : Overwriting previous address contents (2007)

The offending line is the first, __config...
If I comment the line out, it compiles okay, but not wirh the config settings that I want.

How do I set the config items the way I want?


'@ __config _HS_OSC & _WDT_OFF & _MCLRE_OFF
DEFINE osc 8 ' setup the clock for 8 MHz resonator

' configure some defines for the A/D reads
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC SAMPLES 20

; variables
pulse_width var word ' this determines the width of the output pulse, 1.2 ms - 1.8 ms

' initialize the program

TRISIO = %00000000 ' set all GPIO pins to output
ANSEL = %00000000 ' set all GPIO pins to digital
CMCON0 = %00000111 ' Turn of the comparators

' Set TMR0 to interrupt every 20 milliseconds
OPTION_REG = %00000111 ' Set TMR0 configuration 1:256 prescaler
INTCON = %10100000 ' Enable TMR0 interrupts
TMR0 = 101 ' set the timer0 offset for 50.0801 Hz

GPIO = %00000000 ' set GPIO to all 0's
pulse_width = 127 ' center value, 1.5 ms pulse

On Interrupt Goto pulse_out ; this is where we go when the 20ms timer interrupts

main_program:
pulse_width = 255 ' move to end (unlock the trunk)

pause 500 ' give it time to reach the end

pulse_width = 0 ' Move to beginning

pause 500 ' give it time to reach the beginning
end

disable

pulse_out:
TMR0 = 101 ' reset the offset
INTCON.2 = 0 ' Reset timer interrupt flag
pulsout GPIO.0, + 10 pulse_width ' normalize the setting for 1.2 ms to 1.8 ms pulses
resume

end

Demon
- 25th October 2012, 20:52
Have you tried searching for "beginner config"?
http://www.picbasic.co.uk/forum/showthread.php?t=543

Sounds like you are defining the same thing twice.

Robert

HenrikOlsson
- 25th October 2012, 20:52
Hi,

If you have PBP3 then use #CONFIG - check the manual for details.

If you're on an older version you need to do one of two things:
A) Comment out the default config in the .inc file for the target processor (located in your PBP folder). Put the desired config in your PBP source file (like you're trying to do now)
or
B) Edit the .inc file so it contains the desired config. Make sure you back up the original file firts.

Countless of posts has been made on the subject over the years, search the forum and you should find more details if needed.

/Henrik.

PickyBiker
- 26th October 2012, 00:51
"If you have PBP3 then use #CONFIG - check the manual for details."

That was the solution. Thanks!

I think PBP 3 made a nice improvement here allowing a #config block without needing to edit an inc file.