gnupic: Re: [gnupic] stumped with simple led/button circuit
Subject:
Re: [gnupic] stumped with simple led/button circuit
From:
Greg Hill ####@####.####
Date:
1 Mar 2005 01:32:18 +0000
Message-Id: <Pine.LNX.4.44.0502281824070.27667-100000@panda.hillnetworks.net>
On Mon, 28 Feb 2005, Tsu Do Nimh wrote:
> I have, to test my setup, put together a simple circuit w/p16f877a,
> 20MHz crystal, button on PORTA,0, and led on PORTB,0. I've compiled
> assembler code to this target that copies the PORTA input register
> (button) to the PORTB output register.
>
> I checked all the voltages and connections, tried (success) shorting
> the led cathode to ground. I attached an oscilloscope lead to the
> crystal to verify it is ticking ok.
>
> But the button doesn't work. After looking at the hardware, I assume
> the problem is somewhere in the programming of the chip.
>
> I'm using a PS+ and the picp programmer to load the program.
> Disassembling the .hex file results in:
>
> =8<-------
> 000000: 1406 bsf 0x6, 0
> 000001: 1683 bsf 0x3, 0x5
> 000002: 1006 bcf 0x6, 0
> 000003: 1283 bcf 0x3, 0x5
> 000004: 0805 movf 0x5, w
> 000005: 0086 movwf 0x6
> 000006: 2804 goto 0x4
> 002007: 3f32 addlw 0x32
> =8<-------
>
> After loading the corresponding .hex code (gen'td using 'gpasm -o
> ledon.hex ledon.asm'), and disassembling a dump from the chip using
> picp/gpdasm, the code looks like:
>
> =8<-------
> 000000: 0000 nop
> 000001: 1402 bsf 0x2, 0
> 000002: 1002 bcf 0x2, 0
> 000003: 1002 bcf 0x2, 0
> 000004: 0001 dw 0x1 ;unknown opcode
> 000005: 0004 dw 0x4 ;unknown opcode
> 000006: 0086 movwf 0x6
> 000007: 2805 goto 0x5
> =8<-------
>
> Can anyone provide insight as to why I'm getting this different code
> out, or how I might look somewhere else for the source of the problem?
>
> Thanks for your help, in advance.
>
> Yours,
>
> Tsu Do Nimh
Hmm. Tsu Do Nimh. Sounds a lot like Pseu Do Nym. Interesting.
I don't know what's going on with the disassembly, but there are a few
other things I'd suggest that you check. I assume you've already
double-checked that you have connected all Vdd pins to +5 and all Vss pins
to ground, right? What's the situation with the reset pin and the
low-voltage programming pin? Depending on the settings in the
configuration word, leaving these pins floating can cause the processor
not to run. I think the reset pin should be tied high and the low-voltage
programming pin should be tied low (somebody correct me please if I got
those wrong). You can wire them through a resistor (1k, 10k, whatever) to
prevent them from being damaged by over-current if they do happen to be
set as digital output pins.
Greg