HS mode, 20 Mhz
David V. Fansler
S/V Annabelle
.....DFanslerKILLspam
.....MindSpring.com
http://www.dv-fansler.com
-----Original Message-----
From: pic microcontroller discussion list [EraseMEPICLISTspam_OUT
TakeThisOuTMITVMA.MIT.EDU]
On Behalf Of David Duffy
Sent: Thursday, April 04, 2002 12:02 AM
To: PICLIST
spam_OUTMITVMA.MIT.EDU
Subject: Re: [PIC]:16F873 PortC bit 5 revisited - the death of!
At 10:59 PM 03/04/2002 -0500, you wrote:
>Dear PicList - I sent this email out yesterday asking why, or what I am
>doing that would cause port c bit 5 to be pulled low internally to the
chip.
>The ensuing discussion has branched off to my use of using bcf, bsf to
>toggle a bit on and off in order to get a feel for what the PIC was
seeing -
>this may or may not be proper code - it was just there for test purposes.
>As to why bit 5 is hung low - not an educated - or even uneducated guess.
>As I told my wife - I feel sort of like a guy who jumps out of an
airplane -
{Quote hidden}>his chute does not open and he radios for help. The people on the ground
>get into a long winded discussion about what kind of handle he has on his
>rip cord and why it should be something else - never addressing the real
>problem. Sorry if I sound aggravated - I guess I was really hoping someone
>had the answer as to why bit 5 is being held low instead of seeing
>discussion on my use of bcf, bsf.
>
>Thanks to all,
>David
>
>Since my last post, I have simplified my code to almost nothing to try to
>find out why my 16F873 wants to pull port c bit 5 low - the code is below.
>In this case I set port c up then input port C, check to see if bits 0,1,4
>or 5 are low (they are pulled up to 5v by a 220 ohm resistor - pulling them
>down is by a momentary push button switch). If one of the inputs is low
the
{Quote hidden}>code determines which one and jumps to code that then pulses port c bit 3
>either 1, 2, 3 or 4 times to indicate which button is pressed. I then can
>observe the output bit via my oscilloscope. When the code runs in my
>emulator all is well. But when I burn a 16F873 and place it in the circuit
>the output shows 4 pulses without a button being pushed - sure enough bit 5
>is low on the oscope. Pull the 16f873 from the circuit and the pin goes
>high. Something internal to the 16f873 is causing port c bit 5 to be low
>(over riding the 220 ohm resistor). The only peripheral I can find on the
>16f873 that shares port c bit 5 is the Sync Serial Port, but I feel that I
>have disabled it.
>
>If anyone has any hints, I sure would be happy to hear them!
>Thanks,
>David
>
>
> include 'c:\ptools\16f873.inc'
> Fuses _CP_OFF
> Fuses _DEBUG_OFF
> Fuses _WRT_ENABLE_ON
> Fuses _CPD_OFF
> Fuses _LVP_OFF
> Fuses _BODEN_OFF
> Fuses _PWRTE_ON
> Fuses _WDT_OFF
> Fuses _HS_OSC
What speed crystal or resonator are you using?
If it's 4MHz, use XT_OSC mode.
{Quote hidden}>TEMP_B equ 078h ;temporary register
>
> org 0000h
>
>START
>
>INIT_PORTS
> bsf RP0 ;point to bank 1
> bcf RP1 ;
> movlw 10110011b ;set port c to 7->Rx, 6->Tx, 5->Dim, 4->Bright
> movwf TRISC ;3->test out, 2->PWM, 1-> Zero,
0->Hold/Cont
{Quote hidden}> movlw 00h ;load 0 into W
> movwf SSPCON2 ;then into Sync Ser Port Cont 2
> movwf PIE1
> movwf PIE2
> bcf RP0 ;point to bank 0
> movlw 00h ;load 0 into W
> movwf PIR1
> movwf PIR2
> movwf SSPCON ;then into Sync Ser Port Control
>MAIN
> movf PORTC, W ;read port C into W
> movwf TEMP_B ;and into TEMP_B
> andlw 00110011b ;mask off key bits
> xorlw 00110011b ;any bits low?
> btfsc Z ;if key pressed then skip
> goto MAIN ;else jump
> btfss TEMP_B,0 ;if Hold/Cont not set then jump
> goto SCAN_H:C ;else jump
IIRC, you can't have a colon in the middle of a label.
{Quote hidden}> btfss TEMP_B,1 ;if Zero not set then jump
> goto SCAN_ZERO ;else jump
> btfss TEMP_B,4 ;if Brighten not set then jump
> goto SCAN_BRIGHT ;else jump
> btfss TEMP_B,5 ;if Dim not set then jump
> goto SCAN_DIM ;else jump
> goto MAIN
>SCAN_H:C
> bsf Portc,3 ;port C bit 0 low
> bcf portc,3 ;so pulse bit 3 once
> goto MAIN
>
>SCAN_ZERO
> bsf Portc,3 ;port C bit 1 low
> bcf portc,3 ;so pulse bit 3 twice
> bsf Portc,3 bcf portc,3
> goto MAIN
>
>SCAN_BRIGHT
> bsf Portc,3 ;port C bit 4 low
> bcf portc,3 ;so pulse bit 3 three times
> bsf Portc,3
> bcf portc,3
> bsf Portc,3
> bcf portc,3
> goto MAIN
>
>SCAN_DIM
> bsf Portc,3 ;port C bit 5 low
> bcf portc,3 ;so pulse bit 3 four times
> bsf Portc,3
> bcf portc,3
> bsf Portc,3
> bcf portc,3
> bsf Portc,3
> bcf portc,3
> goto MAIN
>
> end
--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.