PDA

View Full Version : Help for a new boy



TDUpiccode
- 14th December 2013, 03:24
Hi All

A bit new to all this but learning fast (I hope), and this seems a stupid question, but I don't know and if you don't know you have to ask so........

I have code which works fine on a 12f683, but I had originally planned to use 12f629 and so want to recode it. Now I know there are certain differences, but at the moment I cant even get simple code to work on the 629.

I have this that works on the 629


' Name : Test44.pbp
' Compiler : PICBASIC PRO Compiler 3.07
' Assembler : PM
' Target PIC : 8-pin PIC12F629
' Oscillator : 4MHz internal
' Description : test file PICBASIC PRO program to show button press on LED.
'

DEFINE PIC12F629, INTRC_OSC,INTRC_OSC_NOCLKOUT,WDT_ON,PWRT_ON,MCLR_O FF, BOD_ON , CPD_OFF , PROTECT_OFF
Define OSCCAL_1K 1 ' PIC12F675, Calibrate internal oscillator

CMCON = 7 ' Analog comparators off
CLEAR

LED var gpio.1 ' Alias GPIO.0 to LED
PB Var GPIO.0 ' Alias GPIO.3 to push button

' Button press turns on LED

If PB = 0 Then ' If button pressed...
low LED ' Turn on LED
Else
high LED ' Turn off LED
Endif

Goto mainloop ' Do it forever
End

However if I add lines after "'Button press ...." such as a short HIGH/PAUSE/LOW/PAUSE sequence all I get is the Led going High and the Prg appears to halt.

If I try similar code on the 683 it works - dont even have the opening DEF in there

Any help gratefully received

Confused Colin

Jerson
- 14th December 2013, 03:29
Colin

You haven't defined the label for 'mainloop' and tell the processor to goto mainloop. You're probably getting errors while compiling this code.

Archangel
- 14th December 2013, 03:33
Please tell us what version of PBP you are using, and if you know whether you are using MPASM or not.

Good catch Jerson . . .

TDUpiccode
- 14th December 2013, 23:09
just checked the code and have got mainloop defined - don't why it didn't copy over.

' Name : Test44.pbp
' Compiler : PICBASIC PRO Compiler 3.07
' Assembler : PM
'Button press turns on LED

mainloop:

If PB = 0 Then ' If button pressed...
low LED ' Turn on LED
Else
high LED ' Turn off LED
Endif

Goto mainloop ' Do it forever

End

I am using PBP3.071 and and I guess MPASM if that is the default installed.

Demon
- 14th December 2013, 23:27
It will be easier for members to help if you post all your code. You don't have any CONFIGs, no oscillator setting, LED is not defined as a beginning.

Are the proper pins digital by default on this device?

Robert

TDUpiccode
- 14th December 2013, 23:44
The earlier code posted has all the detail

Led var GPIO.1 etc

Archangel
- 15th December 2013, 06:03
DEFINE PIC12F629, INTRC_OSC,INTRC_OSC_NOCLKOUT,WDT_ON,PWRT_ON,MCLR_O FF, BOD_ON , CPD_OFF , PROTECT_OFF
Define OSCCAL_1K 1 ' PIC12F675, Calibrate internal oscillator

DOES NOT WORK IN pbp3.xxx which is why I asked you, in fact it does not work in MPASM with ANY version of PBP as it is for the PB assembler which PBP3.xx does not support.


@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BOR_OFF & _FCMEN_OFF & _IESO_OFF

above would be how to config MPASM in PBP versions earlier than PBP3.00


PBP 3.xx configs are done as in below:

#CONFIG
__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _WDT_ON
;__config _CONFIG2, _WRT_OFF & _BOR40V
#ENDCONFIG
All that said you will need to make appropriate changes to what I posted for your particular chip, but that is how to format your configs

TDUpiccode
- 15th December 2013, 13:01
Thanks for the config help