Searching \ for '[PIC] Newbie stuck' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/begin.htm?key=pic
Search entire site for: 'Newbie stuck'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Newbie stuck'
2009\02\23@140414 by Robert Kiely

picon face
2009/2/23 Olin Lathrop <spam_OUTolin_piclistTakeThisOuTspamembedinc.com>

{Quote hidden}

Don't forget that all GPIO pins default to analogue inputs so need to not
only be set to output as you have done but need to be set to digital by
setting the ANSEL register to the correct value and like Olin said the
comparator needs to be disabled too for the pins that are used for that
peripheral to funtion as digital outputs.

Rgds,
Rob

P.S. It's funny how many people spell analogue incorrectly i.e. analog. I
guess maybe it's because of the company Analog Devices ??

2009\02\23@141732 by Adam Field

flavicon
face
>
> P.S. It's funny how many people spell analogue incorrectly i.e. analog. I
> guess maybe it's because of the company Analog Devices ??

Going OT, here in the US, it is always spelled analog. It's another
color/colour word.

2009\02\23@170947 by joseph

face
flavicon
face
P.S. It's funny how many people spell analogue incorrectly i.e. analog. I
guess maybe it's because of the company Analog Devices ??

Mainly the difference between American and British English.  Analogue,
Colour, Catalogue, etc are British spellings.  Let's not forget program and
programme - the latter which is rarely if ever used in American English.

Then there's the ize - ise words.  

My favo(u)rite is manoeuvre.  Definitely not spelled that way in the USA.
:-)

Joe



--------------------------------------------------------------------
mail2web.com – Enhanced email for the mobile individual based on Microsoft®
Exchange - http://link.mail2web.com/Personal/EnhancedEmail


2009\02\23@172249 by olin piclist

face picon face
Robert Kiely wrote:
> P.S. It's funny how many people spell analogue incorrectly i.e.
> analog.

Some sources list "analogue" as a alternate spelling, but unless perhaps
you're accross the pond, the normal is "analog".  Do you also say red,
green, and blue are "colours" instead of "colors"?


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\02\23@222804 by andrew kelley

picon face
On Mon, Feb 23, 2009 at 12:21 PM, Bill Dietrich <.....bill_dietrichKILLspamspam@spam@yahoo.com> wrote:
> Hi,
>
> Just bought some PIC hardware and got stuck trying to get any life
> out of the target board.  I'm just trying to get some LED's to blink.
>
> I'm using MPLAB IDE v8.15a.
> Programmer board is PX-200.
> Target board is PIC-IO-18.
> Chip is PIC16F628A.
>
> My C program is:
>
> #include    <pic.h>
> #include <htc.h>    // Required to interface with delay routines
>
> #ifndef _XTAL_FREQ
>  // Unless already defined assume 4MHz system frequency
>  // This definition is required to calibrate __delay_us() and __delay_ms()
>  #define _XTAL_FREQ 4000000
> #endif
<snip main code, irrelevant>


{Quote hidden}

Aha... where are your configuration bits?  If you dont configure it,
it wont work ever.

> So, what's going on ?  Which board was the "OS" downloaded to, and
> how do I recover from that ?  Is my C program wrong (probably) ?
> How do I start a program running on the target after programming ?

You need to set the configuration bits, either in the source
(recommended) or in the programmer(not so much, but to get it to work
maybe)  The datasheet on the 16f628a can be found at
http://www.microchip.com  That datasheet has a whole section on the
configuration of the config bits.  Yes, although the others are right
about ANSEL/CMCON, it shouldn't affect the operation of the digital
pins that are not hooked up to the comparator.

>From the datasheet:
"TRISA controls the direction of the RA pins, even when
they are being used as comparator inputs. The user
must make sure to keep the pins configured as inputs
when using them as comparator inputs."
"In one of the Comparator modes defined by the
CMCON register, pins RA3 and RA4 become outputs
of the comparators. The TRISA<4:3> bits must be
cleared to enable outputs to use this function."


>
> Thanks,
>
> Bill Dietrich
> bill_dietrichspamKILLspamyahoo.com      http://www.geocities.com/bill_dietrich/
> sailing vessel "Magnolia": 1973 Gulfstar 44 ketch motor-sailer


Andrew

2009\02\25@115516 by Bill Dietrich

picon face
Thanks for the messages from various people.

I copied that C code from a couple of demo programs;
that's why the strange FOR loop syntax, for example.

I tried a simple C program consisting of almost nothing but:
   TRISB = 0;        /* all bits output */
   PORTB = 0x00;        /* turn all on */
and no LED's came on.  There is an LED connected to RB5
on my target board; I should see that come on, right ?

I think I'm having some basic "target is not getting programmed"
problem.  I quit out of MPLAB IDE.  Using PicKit 2 (version 2.40),
I can write-and-verify new hex values to Program
memory and EE memory successfully, but then if I quit PicKit 2, start it again,
and read from the device, the new hex values are gone (back to all FF's).
Didn't power-cycle target or programmer board inbetween.
So I think the PicKit 2 write-and-verify is lying to me, and failing.

If anyone else is using the PX-200 programmer board (PIC programmer board
with USB connector) successfully, I'd like to get some documentation about
it (it seems to have come with none).  Same for the PIC-IO-18 target board.
I'll contact the vendor.

Thanks,

Bill Dietrich
.....bill_dietrichKILLspamspam.....yahoo.com      http://www.geocities.com/bill_dietrich/
sailing vessel "Magnolia": 1973 Gulfstar 44 ketch motor-sailer



     

2009\02\25@120701 by Scott Larson

picon face
On Wed, Feb 25, 2009 at 11:54 AM, Bill Dietrich <EraseMEbill_dietrichspam_OUTspamTakeThisOuTyahoo.com> wrote:
> Thanks for the messages from various people.
>
> I copied that C code from a couple of demo programs;
> that's why the strange FOR loop syntax, for example.
>
> I tried a simple C program consisting of almost nothing but:
>    TRISB = 0;        /* all bits output */
>    PORTB = 0x00;        /* turn all on */
> and no LED's came on.  There is an LED connected to RB5
> on my target board; I should see that come on, right ?

Are your LEDs pulled up or down? This will only work if they're pulled up.


-Scott

2009\02\25@121603 by Tamas Rudnai

face picon face
On Wed, Feb 25, 2009 at 4:54 PM, Bill Dietrich <bill_dietrichspamspam_OUTyahoo.com>wrote:

> I can write-and-verify new hex values to Program
> memory and EE memory successfully, but then if I quit PicKit 2, start it
> again,
> and read from the device, the new hex values are gone (back to all FF's).
> Didn't power-cycle target or programmer board inbetween.
> So I think the PicKit 2 write-and-verify is lying to me, and failing.
>

Sounds like the code protection turned on in the config fuses.

Tamas
--
Rudonix DoubleSaver
http://www.rudonix.com

2009\02\25@121735 by Bob Blick

face
flavicon
face

On Wed, 25 Feb 2009 08:54:34 -0800 (PST), "Bill Dietrich"
<@spam@bill_dietrichKILLspamspamyahoo.com> said:

> I think I'm having some basic "target is not getting programmed"
> problem.  I quit out of MPLAB IDE.  Using PicKit 2 (version 2.40),

> If anyone else is using the PX-200 programmer board (PIC programmer board
> with USB connector) successfully, I'd like to get some documentation

Hi Bill,

Clarify this if you can. You have two different programmers, a PicKit2
and an ICD2 clone(PX-200)?

I was very happy to get a PicKit2, always hated the ICD2.

Could the bad read-back be an LVP pin issue on your PIC? It needs a
pulldown.

Have you put a __CONFIG line in your code to set the fuses? You should
do that. Not having it(and correctly configured) could screw up
everything, especially if the LVP pin is floating.

Cheers,

Bob

--
http://www.fastmail.fm - One of many happy users:
 http://www.fastmail.fm/docs/quotes.html

2009\02\25@122125 by Tamas Rudnai

face picon face
On Tue, Feb 24, 2009 at 1:26 AM, William Chops Westfield <KILLspamwestfwKILLspamspammac.com>wrote:

> >>        for(i = 50 ; --i ;)
> >>            __delay_ms(20);    // delay for 20 milliseconds
> >>
> The second is a form I've never seen, but it is a legal C statement.
>

This is commonly used if you write something like this:

// timeout: 1s while try 50 times doing something...
for (i = 50; --i; __delay_ms(20) ) {
   // do something here...
   if (succeed) {
       break;
   }
}

The reason is some people write it in this way is that you as a code
reviewer can see easily that the developer intended to delay at each
iteration.

Tamas
--
Rudonix DoubleSaver
http://www.rudonix.com

2009\02\25@144305 by olin piclist

face picon face
Bill Dietrich wrote:
> I tried a simple C program consisting of almost nothing but:
>    TRISB = 0;        /* all bits output */
>    PORTB = 0x00;        /* turn all on */
> and no LED's came on.  There is an LED connected to RB5
> on my target board; I should see that come on, right ?

Not necessarily.

First, real physical devices like LEDs tend to obey the laws of physics.
Something has to be connected to its other leg if you want current to flow
thru the LED.

Second, the LED needs to be connected the right way.  It's a diode, so
polarity matters.  If you want the LED to come on when the port pin is low,
you have to connect the cathode to the port pin with the annode to Vdd with
a resistor in series.  Figure the LED will drop about 2V and size the
resistor for about 5mA.

Third, you have to make sure RB5 is really configured as a output.  If that
pin has analog capabilities (D/A or comparator input), then those need to be
explicitly disabled.  Just setting the TRIS bit to 0 in that case is
insufficient.

Fourth, you need to make sure the PIC is actually running else whatever
instructions you write are irrelevant.  This means you have to set all the
config bits according to your setup, including the oscillator config.  You
also need power, making sure all Vss, AVss, Vdd, and AVdd pins are hooked
up.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\02\25@182444 by andrew kelley

picon face
On Wed, Feb 25, 2009 at 11:54 AM, Bill Dietrich <RemoveMEbill_dietrichTakeThisOuTspamyahoo.com> wrote:
> Thanks for the messages from various people.
>
> I copied that C code from a couple of demo programs;
> that's why the strange FOR loop syntax, for example.
>
> I tried a simple C program consisting of almost nothing but:
>    TRISB = 0;        /* all bits output */
>    PORTB = 0x00;        /* turn all on */
> and no LED's came on.  There is an LED connected to RB5
> on my target board; I should see that come on, right ?
>
> I think I'm having some basic "target is not getting programmed"
> problem.  I quit out of MPLAB IDE.  Using PicKit 2 (version 2.40),
> I can write-and-verify new hex values to Program
> memory and EE memory successfully, but then if I quit PicKit 2, start it again,
> and read from the device, the new hex values are gone (back to all FF's).
> Didn't power-cycle target or programmer board inbetween.
> So I think the PicKit 2 write-and-verify is lying to me, and failing.

If it is the same code you posted on the other thread, you are missing
the configuration words.
Check the datasheet and compiler manual on how to set them.

> If anyone else is using the PX-200 programmer board (PIC programmer board
> with USB connector) successfully, I'd like to get some documentation about
> it (it seems to have come with none).  Same for the PIC-IO-18 target board.
> I'll contact the vendor.
>
> Thanks,
>
>  Bill Dietrich
> spamBeGonebill_dietrichspamBeGonespamyahoo.com      http://www.geocities.com/bill_dietrich/
> sailing vessel "Magnolia": 1973 Gulfstar 44 ketch motor-sailer

2009\02\25@221302 by solarwind

picon face
Try PORTB = 0xFF; (not 00)

2009\02\26@075530 by Isaac Marino Bavaresco

flavicon
face
Olin Lathrop escreveu:
> Third, you have to make sure RB5 is really configured as a output.  If that
> pin has analog capabilities (D/A or comparator input), then those need to be
> explicitly disabled.  Just setting the TRIS bit to 0 in that case is
> insufficient.
>  

That's not quite correct. A pin configured for analog input but with
TRISx == 0 will be a digital output. When reading the pin digitally it
will always read zero, but the pin will source or sink current
accordingly with PORTx bit.

If you read the analog value, the value read will be the voltage
actually present at the pin.

This feature helps me to save pins when driving bi-color LEDs. I connect
one terminal of a two terminal bi-color LED to a PIC pin and the other
LED pin to VCC / 2.
When TRISx == 1 the LED is off. With TRISx == 0 and PORTx == 0 the LED
lights green and with TRISx == 0 and PORTx == 1 the LED lights red.
Thus three LED states with just one PIC pin.

I define the pin as analog so when the pin is high-z it won't increase
the Icc of the device.

Regards,

Isaac
__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/

2009\02\26@082242 by Alan B. Pearce

face picon face
>I define the pin as analog so when the pin is high-z
>it won't increase the Icc of the device.

But the Vcc/2 divider is probably drawing more current than the Icc increase
you would see.

2009\02\26@083427 by olin piclist

face picon face
Isaac Marino Bavaresco wrote:
> That's not quite correct. A pin configured for analog input but with
> TRISx == 0 will be a digital output. When reading the pin digitally it
> will always read zero, but the pin will source or sink current
> accordingly with PORTx bit.

Hmm.  I do remember seeing it stated this way in some newer data sheets, but
I also thought I've run into the problem a long time ago where a output
didn't work because the A/D was still configured to use it.  I just checked
with my old 16F876 data sheet, and the schematic for a port A pin with
analog input confirms what you said.

I don't think I've had a occasion to deliberately mix analog and digital on
the same pin, and my development environment pretty much prevents me
accidentally leaving a analog peripheral enabled unintentionally, so I
haven't actually run into this for many years.  Am I just misremembering
this, or is there really some interaction with digital outputs and analog
peripherals?


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.

2009\02\26@085126 by Isaac Marino Bavaresco

flavicon
face
Alan B. Pearce escreveu:
>> I define the pin as analog so when the pin is high-z
>> it won't increase the Icc of the device.
>>    
>
> But the Vcc/2 divider is probably drawing more current than the Icc increase
> you would see.
>  
It is not a passive divider, it is a circuit which stabilizes the
voltage and can sink/source a lot of current because I have lots of
sub-circuits and LEDs that use it.

And yet, I am more concerned about the PIC's Icc because of its safety.
The total consumption of the circuit is not a problem (it consumes a lot
anyway).

Regards,

Isaac
__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/

2009\02\26@142712 by William \Chops\ Westfield

face picon face

On Feb 26, 2009, at 4:48 AM, Isaac Marino Bavaresco wrote:

>> You have to make sure RB5 is really configured as a output.  If that
>> pin has analog capabilities (D/A or comparator input), then those  
>> need to be
>> explicitly disabled.
>
> That's not quite correct. A pin configured for analog input but with
> TRISx == 0 will be a digital output. When reading the pin digitally it
> will always read zero, but the pin will source or sink current
> accordingly with PORTx bit.

Hmm.  That's not my experience, at least with the comparator pins on a  
PIC12F675.  I had the hardest time getting my LEDs to work when I was  
carefully turning off the A-D, but hadn't done anything with the  
comparator config...

BillW


'[PIC] Newbie stuck'
2009\03\02@120529 by Rikard Bosnjakovic
picon face
On Mon, Feb 23, 2009 at 18:21, Bill Dietrich <TakeThisOuTbill_dietrichEraseMEspamspam_OUTyahoo.com> wrote:

> Just bought some PIC hardware and got stuck trying to get any life
> out of the target board.  I'm just trying to get some LED's to blink.

[...]

Hi Bill

What's missing in your code is the configuration word. As others have
pointed out, without configuration you won't get your PIC working
(atleast not in a predictive manner).

Have a look in the include-file "pic16f62xa.h" (in the
HTC-installation). At the bottom of the file you will see some names
regarding the config bits. You will have to consult the 628-datasheet
to find out which features you want (or not), and you specify the
config using the __CONFIG-macro, like this:

__CONFIG(UNPROTECT & LVPDIS & BORDIS & MCLREN & PWRTDIS & WDTDIS & INTIO);

This config will work for your 628a and the blinking LED, but you will
probably have to add "#include <pic16f62xa.h>" (without quotes) to
your code. Also note that all PIC:s does not have the same kind of
config-bits; the above config will not work on a 12F683, for example.

Don't forget to add a pull up-resistor between the MCLR-pin and Vdd.


--
- Rikard - http://bos.hack.org/cv/

More... (looser matching)
- Last day of these posts
- In 2009 , 2010 only
- Today
- New search...