1. 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.
    Dismiss Notice

Command not recognised in Oshon IDE

Discussion in 'Oshonsoft' started by Ian Walters, Sep 21, 2014.

  1. Ian Walters

    Ian Walters New Member

    Joined:
    Sep 21, 2014
    Messages:
    8
    Likes:
    0
    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
     
  2. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    270
    Likes:
    15
    Location:
    Helsinki, Finland
    For example, if the switch is connected to PORTA bit0

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

    or

    loop:
    if PORTA.0=0 then goto loop
    ..........
     
  3. leftfield95

    leftfield95 Member

    Joined:
    Aug 5, 2008
    Messages:
    71
    Likes:
    2
    Location:
    lincs, UK
    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.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Walters

    Ian Walters New Member

    Joined:
    Sep 21, 2014
    Messages:
    8
    Likes:
    0

    Hi Gentlemen

    Brilliant thank you! I will try what you suggest

    Very many thanks
     
  6. Ian Walters

    Ian Walters New Member

    Joined:
    Sep 21, 2014
    Messages:
    8
    Likes:
    0
    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
     
  7. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,236
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    Which PIC type?
    Post your full code, use the INSERT/CODE in the reply on the menu bar.
    E
     
  8. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,306
    Likes:
    914
    Location:
    Rochdale UK
    Nothing wrong here..... What is the compiler complaining about...
     
  9. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,306
    Likes:
    914
    Location:
    Rochdale UK
    Just compiled this in Oshonsoft with no issues at all

    Code (basic):

    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
     
     
  10. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,236
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi,
    Try this, it works for me.

    Code (text):

    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
     
     
  11. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,306
    Likes:
    914
    Location:
    Rochdale UK
    Sorry Eric... We must have answered together.... At least we know he has a problem with the compiler though...
     
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,236
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    ONLINE
    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
     
  13. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,306
    Likes:
    914
    Location:
    Rochdale UK
    I thought he said the compiler rejected the code...... I just assumed it wasn't compiling!!!
     
  14. Ian Walters

    Ian Walters New Member

    Joined:
    Sep 21, 2014
    Messages:
    8
    Likes:
    0
    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
     

Share This Page