Newbie question... why dont this work...??
Hi all,
sorry if I appear to be a thicko newbie, but last week I bought Proton from Crownhill, and I am having a slight (?) headach trying to get my code to work!
For a project I am trying to get an RF module to run three very simple output routines.. flash led, make a sound, do both, etc...
I am using a 12f629, the code seems to compile ok, with no errors, but no matter what I try, the routines always seem to get stuck in a repeating loop. They never break out, or return to their respective gosub calls.. the chip is being programmed / erased with a PicKit1 doofer... Eventually I want to use the rfPIC12F675f
I know I am doing something REALLY stupid, but any comments would be a help.. and I'd like to get this sorted before I commit to making some pcb's!
Cheers in advance,
Shax.
'=================================
' project :
' author :
' date : 06-09-2005
' test device : 12f629
' revision : 0.02b test code
'=================================
Device=12F629 'define processor
Set OSCCAL
Config INTRC_OSC_NOCLKOUT, MCLRE_OFF ' internal 4mhz osc, MCLR internal
' setup ports
TRISB = %11000011 ' define port pin assignments
Symbol LED = GPIO.4 ' LED output on port 4
Symbol DATA_OUT = GPIO.2 ' DATA_OUT output on port 2
Symbol RF_ENABLE = GPIO.5 ' RF_ENABLE output on port 5
'NEXT BIT SETS PORTS IN INITIAL STATE
Low RF_ENABLE
Low LED
Low DATA_OUT
' define variables
Dim tx_delay As Word
tx_delay = 1000
Symbol max_delay = 15000
Dim reps As Byte
Let reps = 0
Dim warp As Byte
GoSub LOOP
GoSub Theme
GoSub loop2
' start of standby routine loop
LOOP:
For reps = 0 To 10
High LED
High RF_ENABLE
DelayMS 50
Low LED
Sound DATA_OUT,[120,12]
DelayMS 5
Sound DATA_OUT,[120,12]
DelayMS 50
Low RF_ENABLE
DelayMS 5000
Next
Return 'never gets here
Theme: Low RF_ENABLE ' i ripped this section from the proton samples to see what would happen... still dont work!
High RF_ENABLE
DelayMS 50
Sound DATA_OUT, [50,60,70,20,85,120] ' this is how far this routine gets ( if selected by first gosub) before repeating if selected!
Sound DATA_OUT, [83,40,70,20,50,20]
Sound DATA_OUT, [70,20,90,120,90,20]
Sound DATA_OUT, [98,160]
DelayMS 500
'-------
For warp = 128 To 255
Sound DATA_OUT, [warp,2]
Next
'-------
Sound DATA_OUT, [43,80,63,20,77,20,71,80,51,20,90,20,85,140,77,20,8 0,20,85,20,90,20,80,20,85,60,90,60,92,60,87,60,96, 70,0,10,96,10,0,10,96,10,0,10,96,30,0,10,92,30,0,1 0,87,30,0,10,96,40,0,20,63,10,0,10,63,10,0,10,63,1 0,0,10,63,20]
DelayMS 50
Low RF_ENABLE
DelayMS 10000
Return
loop2: 'never gets here, unless selected by first gosub
Low LED
High RF_ENABLE
Sound DATA_OUT,[50,12,60,12,70,12,60,12,50,12]
Low RF_ENABLE
Let tx_delay = tx_delay + 5
DelayMS tx_delay
If tx_delay > max_delay Then tx_delay = max_delay
GoTo loop2