Strange problem with simple program - help please


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2010
    Posts
    51

    Default Strange problem with simple program - help please

    I have a 7 segment connected to my 16F690 with the following connections and configuration: My segment B & C are flickering and I cannot figure out why. Please help:
    Code:
    Include "modedefs.bas"
    DEFINE OSC 8
    DEFINE  NO_CLRWDT	1
    
    #CONFIG
        ifdef PM_USED
            device  pic16F690, intrc_osc_noclkout, wdt_on, mclr_on, protect_off
        else
            __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_ON & _PWRTE_ON & _CPD_ON & _BOR_ON & _IESO_OFF & _FCMEN_OFF
        endif
    #ENDCONFIG
    
    	OSCCON = %01110000 ' Internal Oscillator 8MHz
    	PortA=0 : PortB=0 : PortC=0
    	TRISA=0
    	TRISB=0
    	TRISC=0
    ' 4 INPUTS
    	INPUT PORTA.3
    	INPUT PORTB.7
    	INPUT PORTC.0
    	INPUT PORTB.4
    
         	OPTION_REG = %10000010  ' RAPU = off, PS 1:8 to TMR0
          	ANSEL = 0               ' NO ANALOGS
    	CM1CON0=0
    	CM2CON0=0
    
    ' 7 SEGMENT DISPLAY
    	A VAR	PortA.5
    	B VAR	        PortC.6
    	C VAR	PortC.7
    	D VAR	PortC.3
    	E VAR 	PortC.4
    	F VAR 	PortA.4
    	G VAR 	PortC.5
    Pause 1000 ' before start to know if PIC is resetting - all segments will be off for a sec
    
    While 1:
    		A=1 :PAUSE 10 : B=1 : PAUSE 10 : C=1 :PAUSE 10 : D=1: PAUSE 10 : E=1 :PAUSE 10 : F=1 :PAUSE 10 : G=1 : PAUSE 10
    Wend

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Strange problem with simple program - help please

    Hi,
    The chip has more than 8 analog inputs. ANSEL = 0 only sets the first 8 to digital and PortC.6 and PortC.7 which exhibits the issue is AN8 and AN9 respectively. Try adding ANSELH = 0 as well.

    /Henrik.

  3. #3
    Join Date
    Jan 2010
    Posts
    51


    Did you find this post helpful? Yes | No

    Default Re: Strange problem with simple program - help please

    Thanks a lot.
    I missed that. Silly me

Similar Threads

  1. Simple code but strange result - 877A
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 8th May 2011, 19:14
  2. Strange Behaviour - Simple code+DT_INT+16F676
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th February 2010, 18:53
  3. Simple program - Strange problem!
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 19th December 2009, 22:52
  4. Help with simple program
    By mykewl in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 31st July 2008, 08:58
  5. First test program, but strange results
    By bartman in forum General
    Replies: 12
    Last Post: - 19th November 2004, 03:14

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