Comparing values

Started by Mark Adams December 23, 2005
First off Thanks for all of the replies to my post "NEW TO PIC'S" back
on Dec 1. I wound up with a DIY programmer, the 150. It seems easy to
use but it won't program all of the Pics they say it will. Namely the
16F777 and 16F877. I've been working with assembly in MPLAB IDE and
have found the sim tool very helpful.

I am working with a 16F870 and the usart sending out Asynchronus data
to a pc. I would kike to create a loop to send out characters from hex
21 to 7E, most of the print characters. What I would like to know is
how to compare the value of my loop to the last character value to
exit the loop.

I seem to recall Motorola had a zero bit for their accumulator, so you
could exclusive OR two values and exit the loop if the zero bit was
set. What is a good way to do this with a pic.

Thanks
Mark


Exactly the same way. Assuming the test value is in the W register:

xorlw 07Eh or '~'
btfss STATUS, Z
'Continue loop here'
'Exit loop here'

--- Mark Adams <markadams1971@mark...> wrote:

> First off Thanks for all of the replies to my post "NEW TO PIC'S"
> back
> on Dec 1. I wound up with a DIY programmer, the 150. It seems easy to
>
> use but it won't program all of the Pics they say it will. Namely the
>
> 16F777 and 16F877. I've been working with assembly in MPLAB IDE and
> have found the sim tool very helpful.
>
> I am working with a 16F870 and the usart sending out Asynchronus data
>
> to a pc. I would kike to create a loop to send out characters from
> hex
> 21 to 7E, most of the print characters. What I would like to know is
> how to compare the value of my loop to the last character value to
> exit the loop.
>
> I seem to recall Motorola had a zero bit for their accumulator, so
> you
> could exclusive OR two values and exit the loop if the zero bit was
> set. What is a good way to do this with a pic.
>
> Thanks
> Mark
>
My software has no bugs, only undocumented features.



Thanks Chad, I think I must have had tunnel vision, I was stuck on
the "d" destination bit after reading the instruction instructions.

--- In piclist@picl..., Chad Russel <chadrussel@y...> wrote:
>
> Exactly the same way. Assuming the test value is in the W
register:
>
> xorlw 07Eh or '~'
> btfss STATUS, Z
> 'Continue loop here'
> 'Exit loop here'
>
> --- Mark Adams <markadams1971@y...> wrote:
>
> > First off Thanks for all of the replies to my post "NEW TO PIC'S"
> > back
> > on Dec 1. I wound up with a DIY programmer, the 150. It seems
easy to
> >
> > use but it won't program all of the Pics they say it will.
Namely the
> >
> > 16F777 and 16F877. I've been working with assembly in MPLAB IDE
and
> > have found the sim tool very helpful.
> >
> > I am working with a 16F870 and the usart sending out Asynchronus
data
> >
> > to a pc. I would kike to create a loop to send out characters
from
> > hex
> > 21 to 7E, most of the print characters. What I would like to
know is
> > how to compare the value of my loop to the last character value
to
> > exit the loop.
> >
> > I seem to recall Motorola had a zero bit for their accumulator,
so
> > you
> > could exclusive OR two values and exit the loop if the zero bit
was
> > set. What is a good way to do this with a pic.
> >
> > Thanks
> > Mark
> >
> My software has no bugs, only undocumented features.
>




Another nice way to go through loops is with a counter using decfsz.
This'd use two ram locations, one holding the data you're sending, the
other holding the counter. I use decsfz a LOT. For example, in a circular
buffer, I use one counter to keep track of how much space is in the fifo
(increment when I take a byte out, decrement when I put a byte in) and how
many bytes are in the fifo (increment when I put one in, decrement when I
take one out), and figuring out when I need to have the fifo "roll over"
back to the beginning of the buffer space (a rollover counter for stuff
going into the fifo, another for stuff going out - When one of the
counters hits zero, I reinitialize the pointer or index back to the
beginning of the buffer). All of these functions can be done with address
compares and a bunch of math, but using a few bytes of ram for counters
makes the code REAL SIMPLE!

decfsz is your friend!

Harold > Exactly the same way. Assuming the test value is in the W register:
>
> xorlw 07Eh or '~'
> btfss STATUS, Z
> 'Continue loop here'
> 'Exit loop here'
>
> --- Mark Adams <markadams1971@mark...> wrote:
>
>> First off Thanks for all of the replies to my post "NEW TO PIC'S"
>> back
>> on Dec 1. I wound up with a DIY programmer, the 150. It seems easy to
>>
>> use but it won't program all of the Pics they say it will. Namely the
>>
>> 16F777 and 16F877. I've been working with assembly in MPLAB IDE and
>> have found the sim tool very helpful.
>>
>> I am working with a 16F870 and the usart sending out Asynchronus data
>>
>> to a pc. I would kike to create a loop to send out characters from
>> hex
>> 21 to 7E, most of the print characters. What I would like to know is
>> how to compare the value of my loop to the last character value to
>> exit the loop.
>>
>> I seem to recall Motorola had a zero bit for their accumulator, so
>> you
>> could exclusive OR two values and exit the loop if the zero bit was
>> set. What is a good way to do this with a pic.
>>
>> Thanks
>> Mark
> >
> My software has no bugs, only undocumented features. >
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions
> Yahoo! Groups Links >
>


--
FCC Rules Updated Daily at http://www.hallikainen.com



Hi Mark,

Mark Adams <markadams1971@mark...> wrote:

> First off Thanks for all of the replies to my post
> "NEW TO PIC'S" back
> on Dec 1. I wound up with a DIY programmer, the 150.
> It seems easy to
> use but it won't program all of the Pics they say it
> will. Namely the
> 16F777 and 16F877.

I have had a similar problem with KIT128 and solved it
by changing the chipinfo.cid file in the programs
directory. Change the entry ProgramDelay@ or
whatever there is to a higher value (there is a
section for every chip and you only change the one
causing you grief) I would first double the value
(slow) if it works decrease to find optimum. Peter van Hoof



I just tried this and it still is giving me a rom programming error problem.
As I was typing this I tried it again to get the right error description and it programmed the chip. Tried several more times and it it only worked like twice.
 
Thanks
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com]On Behalf Of Peter van Hoof
Sent: Friday, December 23, 2005 12:50 PM
To: p...@yahoogroups.com
Subject: Re: [piclist] Comparing values

Hi Mark,

Mark Adams <m...@yahoo.com> wrote:

> First off Thanks for all of the replies to my post
> "NEW TO PIC'S" back
> on Dec 1. I wound up with a DIY programmer, the 150.
> It seems easy to
> use but it won't program all of the Pics they say it
> will. Namely the
> 16F777 and 16F877.

I have had a similar problem with KIT128 and solved it
by changing the chipinfo.cid file in the programs
directory. Change the entry ProgramDelay@ or
whatever there is to a higher value (there is a
section for every chip and you only change the one
causing you grief) I would first double the value
(slow) if it works decrease to find optimum.Peter van Hoof


--- In piclist@picl..., "Mark Adams" <markadams1971@y...> wrote:
>
> I just tried this and it still is giving me a rom programming error
problem.
> As I was typing this I tried it again to get the right error
description and
> it programmed the chip. Tried several more times and it it only
worked like
> twice.
>

I used to have a programmer which would sometimes program in low
voltage programming mode when I didn't want it to. It was only a
generic programmer so I can forgive it. I remember it was a case of
either grounding or pulling high the pin which selects LVP mode, check
it's handled properly on your hardware, maybe it's not.

ChrisB



Does the protocol in the programmer match the protocol
in the software, this has to be a matched set.
download the diypackXX.zip mentioned in the programmer
documentation.

if you want to run with the latest software you will
have to get a additional 16f628a (of 16f648a for
double the program memory for possible future firmware
versions) if you want to be able to upgrade to the
latest software version.

Another thing I would check is that the power adapter
supplies at least 16 volts (probably has to be lower
than 25 or so volts)

Peter van Hoof

--- Mark Adams <markadams1971@mark...> wrote:

> I just tried this and it still is giving me a rom
> programming error problem.
> As I was typing this I tried it again to get the
> right error description and
> it programmed the chip. Tried several more times and
> it it only worked like
> twice.
>
> Thanks
> -----Original Message-----
> From: piclist@picl...
> [mailto:piclist@picl...]On Behalf Of
> Peter van Hoof
> Sent: Friday, December 23, 2005 12:50 PM
> To: piclist@picl...
> Subject: Re: [piclist] Comparing values > Hi Mark,
>
> Mark Adams <markadams1971@mark...> wrote:
>
> > First off Thanks for all of the replies to my
> post
> > "NEW TO PIC'S" back
> > on Dec 1. I wound up with a DIY programmer, the
> 150.
> > It seems easy to
> > use but it won't program all of the Pics they
> say it
> > will. Namely the
> > 16F777 and 16F877.
>
> I have had a similar problem with KIT128 and
> solved it
> by changing the chipinfo.cid file in the programs
> directory. Change the entry ProgramDelay@ or
> whatever there is to a higher value (there is a
> section for every chip and you only change the one
> causing you grief) I would first double the value
> (slow) if it works decrease to find optimum. > Peter van Hoof > to unsubscribe, go to http://www.yahoogroups.com
> and follow the
> instructions >
> SPONSORED LINKS Microcontroller Microprocessor
> Microchip pic
> Microcontrollers Picmicro Pic
> microcontrollers >
----
> --
> YAHOO! GROUPS LINKS
>
> a.. >
----
> -- >




Another trick I have learned if your programmer will allow it, is to
program the config bits first. This will disable the LVP.

Chad

--- Chris <fixitsan@fixi...> wrote:

> --- In piclist@picl..., "Mark Adams" <markadams1971@y...>
> wrote:
> >
> > I just tried this and it still is giving me a rom programming error
>
> problem.
> > As I was typing this I tried it again to get the right error
> description and
> > it programmed the chip. Tried several more times and it it only
> worked like
> > twice.
> >
>
> I used to have a programmer which would sometimes program in low
> voltage programming mode when I didn't want it to. It was only a
> generic programmer so I can forgive it. I remember it was a case of
> either grounding or pulling high the pin which selects LVP mode,
> check
> it's handled properly on your hardware, maybe it's not.
>
> ChrisB >
>


My software has no bugs, only undocumented features.



> Another trick I have learned if your programmer will allow it, is to
> program the config bits first. This will disable the LVP.

That won't help, at least not always, because erasing clear the fuses,
which enables LVP. And after erasing you must reset the chip to start
programming, so at that moment you reset it with LVP enabled.

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu