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

PORTC output

Discussion in 'Oshonsoft' started by graemeian, Nov 19, 2015.

  1. graemeian

    graemeian New Member

    Joined:
    Jul 22, 2008
    Messages:
    17
    Likes:
    0
    I am using a PIC16f630. and Oshonsoft
    In my code , if I use Toggle PORTC.1, all works well.
    I can see where it does the page setup for PORTC on the watch page
    If I use PORTC.1=0. It is gambler's choice as I cannot see where the status bits are changed if needed for PORTC. If I write a simple high/low loop, I may or may not get a square wave on the output pin.
    If I try ASM:LATC,1=0, I get a compile error. The PIC text and Dario both suggest that one uses LATx to write to digital ports. (Dario is one of the strong supporting writers on the PIC forum page.)
    What is the preferred way to control output states of the pins using Oshonsoft.
    Thank you.
     
    Last edited: Nov 19, 2015
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,163
    Likes:
    909
    Location:
    Rochdale UK
    First check the pins are set to digital ( ANSELC = 0).. Second! That chip hasn't got LATCH registers...

    The RMW issue is only with capacitive loads... Switching an LED fast will not give you any real trouble...

    Have you a code snippet so we can see what gives??
     
  3. graemeian

    graemeian New Member

    Joined:
    Jul 22, 2008
    Messages:
    17
    Likes:
    0
    Sorry about the LATCH thing. I have a 16f630 talking to a 16F1455 that is talking to a PC. I was looking at the wring app notes.

    I have something like this:
    OPTION.0 = 0
    OPTION.1 = 1
    OPTION.2 = 1
    OPTION.3 = 1

    TRISC = %00001000 'SETS THE PORT STATUS
    TRISA = %11111111
    PORTC.5 = 1 'RED LED off
    For i = 1 To 10
    WaitMs 50
    PORTC.5 = 0 'RED LED on
    WaitMs 10
    ASM: CLRWDT
    PORTC.5 = 1 'RED LED off
    Next i
    'The above works as I expect with red LED flashing
    loop:
    'some other code including IF THENs that can skip the below code but it is now commented out.
    'and now...

    for I = 1 to 20
    PORTC.0 = 1
    waitMs 250
    ASM: CLRWDT
    PORTC.0=0
    waitMs 250
    ASM: CLRWDT
    NEXT i

    'some more code
    Sleep
    NOP
    Goto loop:

    In the second loop, I am turning on/off a 10mA transmitter.
    I do not see a voltage toggle. When I replace the "PORTC.1=" pair with a toggle ,
    I see the toggle on an o-scope.
    I will get back to the PIC later today and add BCF and BSF to the status pages to see if it makes a difference.
    Thanks.
     
    Last edited: Nov 19, 2015
  4. dave

    Dave New Member

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


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,163
    Likes:
    909
    Location:
    Rochdale UK

    I still can't see where you turn the ADC off!!!

    With Oshonsoft you can use the ALLDIGITAL command... Or use ANSELC = 0.. The analogue module is on by default,,, You have to turn it off!
     
  6. graemeian

    graemeian New Member

    Joined:
    Jul 22, 2008
    Messages:
    17
    Likes:
    0
    Thank you very much Ian. At some time yesterday, I had commented out the alldigital component hidden in the top of the program.
    Starting fresh today, the program is going as expected.
    Thanks again.
     

Share This Page