Please explain me WHY!


Closed Thread
Results 1 to 7 of 7
  1. #1

    Default Please explain me WHY!

    I am using PIC16F690.
    I am wondering why when I use the following program:
    "
    intcon=0
    cm1con0=0
    cm2con0=0
    ansel=0
    anselh=0
    trisc=0
    portc=0
    define OSC 4
    option_reg = %00001000

    main:
    high portC.0
    high portC.1
    high portC.2
    high portC.3
    pause 1000
    low portc.0
    low portc.1
    low portc.2
    low portc.3
    pause 1000
    goto main
    "
    All leds connected to PORTC work as expected.
    AND why they don't work when I use the following code:
    "
    intcon=0
    cm1con0=0
    cm2con0=0
    ansel=0
    anselh=0
    trisc=0
    portc=0
    define OSC 4
    option_reg = %00001000

    main:
    high portC
    pause 1000
    low portC
    pause 1000
    goto main
    "

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Try adding this to your loading values:

    trisC = %00000000


    This will set your portC as outputs.
    The zeros fromleft to right are portC.7, portC.6, portC.5, portC.4, portC.3, portC.2, portC.1, portC.0.
    You can changed the 1's or 0's depending on what you want them to be. In your case, all zeros for outputs.

    or
    'add your stuff here'
    trisC = %00000000

    Main:
    PORTC = %00001111
    pause 1000
    PORTC = %11110000
    pause 1000
    Goto Main

  3. #3


    Did you find this post helpful? Yes | No

    Default

    for tris, 0 is output and 1 is input

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by financecatalyst View Post
    I am using PIC16F690.
    I am wondering why when I use the following program:
    "
    intcon=0
    cm1con0=0
    cm2con0=0
    ansel=0
    anselh=0
    trisc=0
    portc=0
    define OSC 4
    option_reg = %00001000

    main:
    high portC.0
    high portC.1
    high portC.2
    high portC.3
    pause 1000
    low portc.0
    low portc.1
    low portc.2
    low portc.3
    pause 1000
    goto main
    "
    All leds connected to PORTC work as expected.
    AND why they don't work when I use the following code:
    "
    intcon=0
    cm1con0=0
    cm2con0=0
    ansel=0
    anselh=0
    trisc=0
    portc=0
    define OSC 4
    option_reg = %00001000

    main:
    high portC
    pause 1000
    low portC
    pause 1000
    goto main
    "
    Can't tell you why, except <b>maybe </b>it's not supposed too, You CAN do this:
    PortC = 255
    pause 1000
    PortC = 0

    Put ADCON0 = 0 in to disable the A/D converters too
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Sep 2009
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Hi.
    Joe and Marc told you what to do to get desired result, I'll only add that the reason behind it is: high & low are commands that work with one pin you specify not the whole port...

  6. #6


    Did you find this post helpful? Yes | No

    Default

    CMCON = 7 will tuen off the comparator module, if your chip has this.

    Can you post a picture of your project? It would be nice to see how you got everything setup.

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    Would be interesting to compare the produced asm code with " High PORTC " vs " High PORTC.1 " ...

    Explanation is nowhere else ...

    I Still haven't found a use for the first one ... Performs some kind of Read then Write Port sequence.

    Alain
    Last edited by Acetronics2; - 29th September 2009 at 08:12.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. i need more explain
    By lo0oly in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th April 2009, 13:55
  2. 16F676 Please explain this problem...
    By Jayhovah in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th May 2008, 21:30
  3. Replies: 8
    Last Post: - 14th April 2008, 06:58
  4. Please explain about this program
    By wafagenius in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th October 2006, 01:25
  5. Please explain PORTB.0[i]
    By blainecf in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd July 2006, 01:31

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts