Turns out it was an issue with wiring the reset pin, although I will investigate using _MCLRE_OFF, but it doesn't hurt in my usage to not have the RA5 pin available. I'm getting the high programming voltage from the PicKIT2.

Thanks for the assistance. (And I will probably reverse the drives of my LEDs to be sinking to the pic instead, thanks for the tip).


On Sun, Nov 24, 2013 at 6:50 AM, Richard Gray <richard@reallyrathergood.com> wrote:
These are just some thoughts that spring to mind, so don't take me too
seriously...

1. Digital output pins on PICS are usually programmable as either inputs or
outputs, and they default to inputs.

2. Most digital IC's, regardless of what they do can sink more than they can
source. So, an LED to ground might not be such a good idea as turning it around
and running it from the positive rail, although the sense is reversed of
course. What you have described might be working, but the LED is lighting so
weakly that you cannot see it - 10k is a bit big. A 'scope or good high
impedance DMM might be a better tool.

3. Check that your oscillator is actually oscillating, if you can. A scope is
handy here, again.

4. So many people omit to do this: I know that C is preferable to assembly
language, but have a look at the assembler output from the compiler and then
have a look to see if the instructions being emitted make sense. You might find
that you're just writing to memory locations rather than doing any real I/O,
for example. What you're trying to do here should only amount to a few
instructions, so check that these are correct.

Just thoughts, but (4) is very worthwhile. It's a while since I played with
PICs, but they're a bit quirky and you have to go through the motions to check
that you're not doing something daft.

On Sunday 24 November 2013 12:07:13 Michael du Breuil wrote:
> I'm confident its user error, but I seem to be unable to program my
> PIC16F628A (it's my first foray into the world of PICs, been working with
> arm M4's). All I'm trying to do is turn on LED outputs, but I this doesn't
> seem to be working. I'm trying to use the internal 4MHz oscillator, all the
> port A and B pins (so everything except for VDD and VSS) are connected to a
> 10K resistor and LED. This is all done on a breadboard, so it's possible
> there is an error in the wiring, but it appears to be correct.
>
> I'm using a PicKIT 2 to program it (and it can correctly auto identify the
> device as a PIC16F628A) and believes it successfully flashes the device.
> This leads to me to believe I have a good chip, and the ICSP worked out
> correctly.
>
> I'm attempting to build with SDCC, with the appended code, but I don't get
> any thing on any of the output pins, it simply sits there after power on.
> Are there any obvious errors here?
>
> Thanks for your time.
>
>
> ///////////////////////////////////////////////////////////////////////////
> ////////// #include "pic16f628a.h"
>
> unsigned int __at 0x2007 __CONFIG = _INTOSC_OSC_NOCLKOUT &      // Internal
> oscillator
>                                 _WDT_OFF        &       // No Watchdog
>                                 _LVP_OFF        &       // No Low-Volt
> Program.
>                                 _DATA_CP_OFF    &       // No Code Protect
>                                 _PWRTE_ON;
>
> static unsigned char count;
>
> void main(void) {
>         CMCON |= 0x07;  // Disable comparators.  NEEDED FOR NORMAL PORTA
>         TRISB = 0x00;   // Set port B as all outputs
>         TRISA = 0x00;   // Set port A as all outputs
>         PORTA = 0xFF;
>         PORTB = 0xFF;
>
>         while(1) {}
> }

--
Richard.
PGP Key-id: 0x5AB3D350

Be careful of reading health books, you might die of a misprint.
                -- Mark Twain

------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user