I'm very much a novice with microchips / programming and my sole interest is using them for simple robotice animation of models.
I've been using an evaluation copy of Proton IDE so far but now want to write a program longer than this will allow so I bought a copy of PIC16 from Oshon. The models are actuated by a push switch so in Proton I've been using the IF / THEN command string.
The problem I've got is that in Proton I use the command "nop" (no operation) to instruct the chip to do nothing if the switch is low before returning to the Main command, however in PIC16 this "nop" is not recognised and I can't find an alternative syntax to use!
I'm doing something wrong here? I tried all these suggestions but none of them were recognised!
This is what I have written:
TRISB = 0
TRISA = 1
Symbol switch = PORTA.3
Symbol led2 = PORTB.4
Symbol led1 = PORTB.3
Symbol schip = PORTB.5
Symbol theatre = PORTB.1
Symbol fan = PORTB.2
main:
While PORTA.3 = 0
Wend
start:
All I want to do is to get the program to start when the switch on PORTA.3 is pressed making it high but Oshon doesn't recognise this?
I've tried other variations including the IF, THEN, ELSE and ENDIF commands but Oshon seems blind to them? eg
If switch = 1 then
Goto start
Else
goto main
Endif
(Can anyone quote me the correct syntax for this string?)
I'm very much a "newbie" at programming PIC chips with BASIC and am using it to animate scale models so my knowledge is limited to "need to know". I would be very grateful to anyone who can advise on this?
Just compiled this in Oshonsoft with no issues at all
Code:
TRISB = 0
TRISA = 1
Symbol switch = PORTA.3
Symbol led2 = PORTB.4
Symbol led1 = PORTB.3
Symbol schip = PORTB.5
Symbol theatre = PORTB.1
Symbol fan = PORTB.2
main:
While PORTA.3 = 0
Wend
start:
If switch = 1 Then
Goto start
Else
Goto main
Endif
End
AllDigital
TRISB = 0
TRISA = %00001000
Symbol switch = PORTA.3
Symbol led2 = PORTB.4
Symbol led1 = PORTB.3
Symbol schip = PORTB.5
Symbol theatre = PORTB.1
Symbol fan = PORTB.2
main:
While PORTA.3 = 0
Wend
start:
Toggle PORTB.7 'test ONLY
If switch = 1 Then
Goto start
Else
Goto main
Endif
... Alldigital' missing so PORTA was as Analog default
TRISB = 0 TRISA = 1 ' Only PORTA.1 set as Input [ but not used in program]
Symbol switch = PORTA.3 ' he has PORTA.3 TRISed as Output
Symbol led2 = PORTB.4
Symbol led1 = PORTB.3
Symbol schip = PORTB.5
Symbol theatre = PORTB.1
Symbol fan = PORTB.2
main:
While PORTA.3 = 0' Output pin!
Wend
start:
All I want to do is to get the program to start when the switch on PORTA.3 is pressed making it high but Oshon doesn't recognise this?
I've tried other variations including the IF, THEN, ELSE and ENDIF commands but Oshon seems blind to them? eg
If switch = 1 then ' it was an Output pin!
Goto start
Else
goto main
Endif
Copied the code and pasted it in, it compiles and loads and the PIC runs perfectly!
Very, very many thanks, I think I now understand what I was doing wrong. Still an awful lot to learn but progressing slowly and really appreciate the time and effort you folks put into this forum.