Strange Behavour of PortC.5


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Location
    UK-Midlands
    Posts
    84

    Default Strange Behavour of PortC.5

    Hi,

    I know this is something I will kick myself for..

    Simple circuit with PortC 4,5,6 and 7 set as inputs. But PortC. 5 will not trigger the test LED as shown in program below. Have changed PIC (18F2525) and checked circuit.

    Any help will save whats left of my sanity!
    Bob

    **********************************************
    DEFINE OSC 20 ' PIC18F2525

    INTCON2.7 = 0 ' Enable weak pull-ups
    ADCON0 = $00 ' Disable Analog
    ADCON1 = $0F ' PORTB ALL DIGITAL
    CMCON = $07 ' Compartors off
    TRISB = %11110000 ' 0,1,2 & 3 set to OP
    TRISC = %11110100 ' 0,1 & 3 set to OP.
    PORTB=$0F
    PORTC=$08

    T4 VAR BYTE ' temp byte store
    LedG VAR PORTB.0
    LedY VAR PORTB.1
    LedR VAR PORTB.3
    BUZ VAR PORTC.3

    start:
    BUZ=1 ' buzzer off
    LedR = 0 ' led off
    LedG = 0 ' led off
    LedY = 0 ' led off

    PAUSE 500
    t4=portc/16 ' Read the high 4 IPs. move to low byte
    if (t4 & 0010)=0 then
    ledY=1
    pause 500
    endif
    if (t4 & 0100)=0 then
    ledY=1
    pause 500
    endif
    if (t4 & 1000)=0 then
    ledG=1
    pause 500
    endif
    if (t4 & 0001)=0 then
    ledG=1
    pause 500
    endif
    GOTO start
    end
    ****************************************

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


    Did you find this post helpful? Yes | No

    Default

    i'm about to sleep, but can you post your config fuses setting or your compiled HEX ?

    Make sure you have selected HS OSC and the supply line is noise-free.

    Is there any pull-up on PORTC?

    but... let's see if the remaining brain cell may think of something else...
    Code:
    if PORTC.5=0 then
    	ledY=1
    	pause 500
    	endif
    
    if PORTC.6=0 then
    	ledY=1
    	pause 500
    	endif
    
    if PORTC.7=0 then
    	ledG=1
    	pause 500
    	endif
    
    if PORTC.4=0 then
    	ledG=1
    	pause 500
    	endif
    
    GOTO start
    end
    not tested yet...

    But... erm..
    Code:
    PAUSE 500
    t4=portc/16 ' Read the high 4 IPs. move to low byte
    if (t4 & %0010)=0 then
    ledY=1
    pause 500
    endif
    if (t4 & %0100)=0 then
    ledY=1
    pause 500
    endif
    if (t4 & %1000)=0 then
    ledG=1
    pause 500
    endif
    if (t4 & %0001)=0 then
    ledG=1
    pause 500
    endif
    GOTO start
    end
    seems you forgot some %??? or it's a copy/paste error?
    Last edited by mister_e; - 15th July 2007 at 00:44.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Hello BobP, Mister_e,
    Do you think SSPCON1 register may have effect on PortC? I was thinking,
    SSPCON1= %00000101 ' to turn off SDO on PortC.5
    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.

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


    Did you find this post helpful? Yes | No

    Default

    POR value of SSPCON1=0, so it's already disable... but yes never trust it
    Steve

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

  5. #5
    Join Date
    Mar 2004
    Location
    UK-Midlands
    Posts
    84


    Did you find this post helpful? Yes | No

    Smile

    First many thanks for all the quick replies.

    Second... I am now kicking myself around the room.

    mister_e got it in one, I had forgotten to use the binary '%' symbol. The way 3 of the 4 inputs worked threw me completly and I thought it was periphal settings....

    Thanks to all again,
    Bob

Similar Threads

  1. Sony LanC Program
    By l_gaminde in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 3rd October 2009, 19:43
  2. Strange pic 16f877a memory loss
    By DavyJones in forum General
    Replies: 23
    Last Post: - 6th July 2009, 20:27
  3. Strange problem with Serin/Serout on 16F628
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 22nd August 2008, 00:16
  4. Strange ADC behaviour
    By ruijc in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 12th December 2007, 20:03
  5. Strange ASM file
    By barkerben in forum General
    Replies: 2
    Last Post: - 29th November 2004, 18:54

Members who have read this thread : 0

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