PDA

View Full Version : Strange problem with simple program - help please



Tina10
- 28th August 2013, 12:13
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:


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

HenrikOlsson
- 28th August 2013, 12:41
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.

Tina10
- 28th August 2013, 16:32
Thanks a lot.
I missed that. Silly me ;)