Port Values


Closed Thread
Results 1 to 5 of 5

Thread: Port Values

  1. #1

    Default Port Values

    Hi,

    I have a simple Question,but I can not find a Answer.
    I have a Pic 16F870 And I want to use My PortC as High/Low,I now how to do this but can I do this like here:

    Data @1,3,6,12,9

    For Counter = 1 to 4
    Read Counter,State

    PortC = State
    Gosub DelayCheck

    Next Counter


    3 is PortC = %00000011 and 6 is PortC = %00000110 and so on.

    Can I do this.

    Thanks.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Sure you can do this, but don't forget to set the TRISC register at the top of your code to configure your i/o as output.

    Code:
    TRISC=0 ' configure all PORTC I/Os to output
        '
        '
        '
        '
    PORTC=%00001010 ' Write to PORTC
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Thanks Mister,
    I can use decimal numbers like here PortC=3 and this don't disturbe my Hserin Communication on PortC.?!

    Thanks.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Mmm, interesting point, i've never think about it.

    A simple experimentation here reveal that it doesn't cause ANY problem as long as you did a HSEROUT before writing to PORTC. Once you did it, those RX and TX I/Os are dedicated to HSERIN/HSEROUT only.

    i tried...
    Code:
        '
        '    Pic Configuration
        '    =================
        @ __CONFIG _XT_OSC & _WDT_ON & _PWRTE_ON & _BODEN_ON & _LVP_OFF                  
             ' XT (4Mhz) oscillator
             ' Enable watch dog timer
             ' Enable power up timer
             ' Enable brown out detect
             ' Disable low voltage programming
                 
        '
        '    Hardware configuration
        '    ======================
        TRISC=%10000000 ' PORTC.7 as input => USART RX,
                        ' Others as output
    
        '
        '    Serial Communication definition
        '    ===============================
        DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
        DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
        DEFINE HSER_SPBRG 25  ' 9600 Baud @4MHz, 0.16%
        DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
        '   
        '    Variables definition 
        '    ===================
        CounterA    var byte
    
        '
        '    Main program
        '    ============
        HSEROUT [0]
    Start:
        PORTC=%11111111
        PAUSE 500
        PORTC=0
        PAUSE 500
        GOTO START
    If you use it, you'll discover that nothing happen to PORTC.6 and PORTC.7... well they stay at their usual levels... High.

    Now a slight better test...
    Code:
    Start:
        HSEROUT ["Send me data...",13,10]
        hserin [DEC Countera]
        PORTC=countera
        GOTO START
    Use MicroCode Serial Communicator to do you Tests... it still work
    Last edited by mister_e; - 2nd January 2007 at 20:40.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Yes its Working!

    I forgot this TRISC=0 :-)

    Thanks Mister

Similar Threads

  1. Change On Interrupt, PIC16F884
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 14th November 2008, 17:25
  2. port config.
    By tamertokgoz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th July 2008, 12:25
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. 8 port Signal Loss Detector, possible to use a pic?
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th March 2006, 15:59
  5. STATUS re-curtain W
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 15:21

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