Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Command not recognised in Oshon IDE

Status
Not open for further replies.

Ian Walters

New Member
Hi

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!

An help or suggestions would be very welcome!

Best regards
 
For example, if the switch is connected to PORTA bit0

While PORTA.0=0
Wend
..........

or

loop:
if PORTA.0=0 then goto loop
..........
 
in proton basic i think the NOP command is used like this ;

ASM
nop
nop
nop
nop
nop
nop
nop
nop
ENDASM


For Oshon PIC basic it is used like this ;

ASM: NOP
ASM: NOP
ASM: NOP
ASM: NOP
ASM: NOP
ASM: NOP
ASM: NOP
ASM: NOP


Is this what you mean.
 
Hi Gentlemen

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?

PS please write slowly and use little words!

Thanking you in advance
 
hi,
Which PIC type?
Post your full code, use the INSERT/CODE in the reply on the menu bar.
E
 
If switch = 1 then
Goto start
Else
goto main
Endif

(Can anyone quote me the correct syntax for this string?)
Nothing wrong here..... What is the compiler complaining about...
 
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
 
hi,
Try this, it works for me.

Code:
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
 
His main problem was as follows.



... 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
 
Hi Gents

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.

Best regards
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top