Searching \ for '[PIC] RS232 serial example code for a PIC16F84A' 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/ios.htm?key=rs232
Search entire site for: 'RS232 serial example code for a PIC16F84A'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] RS232 serial example code for a PIC16F84A'
2008\09\06@031253 by Xiaofan Chen

face picon face
On Sat, Sep 6, 2008 at 2:37 PM, Grant Brown <spam_OUTgrantTakeThisOuTspamsitedoc.com.au> wrote:
> Hi List,
>
> Could any one please point me to a RS232 serial example in "C" for a
> PIC16F84A.
>
> I have been googling heaps and seem to only find assembler code,
>
> However I need an example suitable for the MicroChip C18 compiler

Forget about 16F84A if you want to use MPLAB C18. It is only
for PIC18. You can use 18F1320 or similar as good start PICs
if you go for PIC18 and MPLAB C18.

Xiaofan

2008\09\06@045529 by Jan-Erik Soderholm

face picon face
Xiaofan Chen wrote:
> On Sat, Sep 6, 2008 at 2:37 PM, Grant Brown <.....grantKILLspamspam@spam@sitedoc.com.au> wrote:
>> Hi List,
>>
>> Could any one please point me to a RS232 serial example in "C" for a
>> PIC16F84A.
>>
>> I have been googling heaps and seem to only find assembler code,
>>
>> However I need an example suitable for the MicroChip C18 compiler
>
> Forget about 16F84A if you want to use MPLAB C18. It is only
> for PIC18. You can use 18F1320 or similar as good start PICs
> if you go for PIC18 and MPLAB C18.
>
> Xiaofan


And forget the 84A even if you'd want to say with the PIC16 line...

2008\09\06@094535 by Grant Brown

flavicon
face
Hi Guys,

Its not so much that I am looking to use a PIC16F84A for a new product.

Its a case of thats the pic that I have on  a demo board so I want to
use it as a learning curve tool to get myself up to speed programing PIC's.

I just need a couple of 'C" example codes and that will get me started.

Don't want to learn assembler just "C" for PICs.

If I can not use the C18 compiler (as I already have it) which "C"
compiler should I use for the PIC16F84A device.

Kind Regards
Grant Brown

Jan-Erik Soderholm wrote:
{Quote hidden}

--
Kind Regards
Grant Brown

SiteDoc Pty Ltd
mob: 0412 926 995
http://www.sitedoc.com.au
__________________________________________________________________________________________________________
This email message together with any attachments is intended only for the addressee(s) and contains information that may be confidential and/or copyright.  If you are not the intended recipient, please notify the sender by reply email (or telephone SiteDoc Pty Ltd on +61 2 42291185) and immediately delete this email together with any attachments from your computer. If you are the intended recipient, you must not copy, disclose, reproduce or distribute this communication together with any attachments without the authority of SiteDoc Proprietary Limited. No representation is made that this email or any attachments are free of viruses. Virus scanning is recommended and is the responsibility of the recipient. Unless specifically stated by the sender as the views of SiteDoc Proprietary Limited, any views expressed in this message are those of the individual sender, and no responsibility will be borne by SiteDoc Proprietary Limited for its content or outcomes.

2008\09\06@095610 by olin piclist

face picon face
Grant Brown wrote:
> Its a case of thats the pic that I have on  a demo board so I want to
> use it as a learning curve tool to get myself up to speed programing
> PIC's.

You could get a better project board, like my ReadyBoard-01
(http://www.embedinc.com/products/ready01).  You can plug in a variety of
PIC 16 and PIC 18, like 16F886, 18F2620, etc.

> I just need a couple of 'C" example codes and that will get me
> started.
>
> Don't want to learn assembler just "C" for PICs.

Really bad idea.  While it's fine to eventually program in C, on these small
systems you always need to be aware of the hardware realities that compilers
try to hide from you.  If you don't learn that first, you'll be constantly
bumping into seemlingly strange and inexplicable problems.  Starting with a
compiler will actually make the learning worse since the compiler will try
to hide the details from you that you need to learn.

If you are new to PICs and don't have a particular project in mind, I
wouldn't bother with the PCI 16 series, and definitely not the archaic and
obsolete 16F84.


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

2008\09\06@154604 by Jan-Erik Soderholm

face picon face
Grant Brown wrote:
> Hi Guys,
>
> Its not so much that I am looking to use a PIC16F84A for a new product.
>
> Its a case of thats the pic that I have on  a demo board

Then that demo-board is just as out-dated as the 84A itself.
You are realy doing yourself a disservice by using it.

> so I want to
> use it as a learning curve tool to get myself up to speed programing PIC's.
>
> I just need a couple of 'C" example codes and that will get me started.
>
> Don't want to learn assembler just "C" for PICs.

Now, you'll probably need to know some assembler anyway to be
able to write any reasonable good C code. At least on
the small devices such as the 84A.

> If I can not use the C18 compiler (as I already have it)

"If" ?
If you had done *any* homework at all, you should know
that the C18 compiler is targeted at the PIC18-series
of PIC processors.


> which "C"
> compiler should I use for the PIC16F84A device.

Pesonaly, I'm not sure a C-compiler is the right
tool at all for that old processor.

2008\09\07@004340 by Byron Jeff

flavicon
face
On Sat, Sep 06, 2008 at 09:44:33AM -0400, Grant Brown wrote:
> Hi Guys,
>
> Its not so much that I am looking to use a PIC16F84A for a new product.
>
> Its a case of thats the pic that I have on  a demo board so I want to
> use it as a learning curve tool to get myself up to speed programing PIC's.

I understand. But the advice that you've been given is very good advice.
Your sample application is a perfect reason not to use a 16F84A.

Take a read of my comparison page on the subject:

http://www.finitesite.com/d3jsys/16F88.html

>
> I just need a couple of 'C" example codes and that will get me started.

Again the issue is that because of the limitations on the part, the only
code that you'll find is bitbanged serial. And while that's probably fine
in special circumstances, under ordinary usage, using the hardware USART in
other parts is a much easier circumstance to handle.

> Don't want to learn assembler just "C" for PICs.

I'm not really talking about a language issue. This advice is true no
matter what language you are programming the part.

But as an aside, you should still learn assembly well enough to read it.
Often you'll only get a piece of code in assembly. So having a reading
level knowledge will help in your translation.

>
> If I can not use the C18 compiler (as I already have it) which "C"
> compiler should I use for the PIC16F84A device.

SDCC is well established for 16F parts. Also you can get the Lite version
of the Hi-Tech C compiler.

But please trust the advice you've been given. Because of its limitations
with hardware peripherals, no matter what code you get for the 16F84A
you'll end up twisting yourself in knots trying to manage more than one
task because you have to do it all in software.

The 16F88, 16F628, and 16F648A are all virtual drop in replacements for the
16F84A, Each carries periperals that will simplify your programming task.

For a sample of a SDCC based C application that seems to send morse code via the
hardware USART, check this code out:

http://homepage3.nifty.com/ARTWEB/pic1.files/sac2.c

Hope this helps.

BAJ

2008\09\07@023907 by Grant Brown

flavicon
face
Hi Jan and other's that replied,

Thank you for your feed back. Its a shame that its was so negative.

Whist the PIC16F84A maybe old its not completely useless.

Its interesting given your comments that NSW TAFFE still uses the 16F84A
to teach MCU programming. Its actually where I got the test board from
as I have a friend that works in that department.

I also wonder how much industrial equipment is still in use around the
world that has 16F84A chips in them. Just because something is a bit
older and slower than the latest u-bueat does not mean it should be
discarded.

Over many years now I have tought a large number of appretices and that
has shown me that one does not teach and or help new comers by being
negative.

Anyway thank you for your assistance and I will take on-board your advice.

Kind Regards
Grant Brown

Jan-Erik Soderholm wrote:
{Quote hidden}

--
Kind Regards
Grant Brown

SiteDoc Pty Ltd
mob: 0412 926 995
http://www.sitedoc.com.au
__________________________________________________________________________________________________________
This email message together with any attachments is intended only for the addressee(s) and contains information that may be confidential and/or copyright.  If you are not the intended recipient, please notify the sender by reply email (or telephone SiteDoc Pty Ltd on +61 2 42291185) and immediately delete this email together with any attachments from your computer. If you are the intended recipient, you must not copy, disclose, reproduce or distribute this communication together with any attachments without the authority of SiteDoc Proprietary Limited. No representation is made that this email or any attachments are free of viruses. Virus scanning is recommended and is the responsibility of the recipient. Unless specifically stated by the sender as the views of SiteDoc Proprietary Limited, any views expressed in this message are those of the individual sender, and no responsibility will be borne by SiteDoc Proprietary Limited for its content or outcomes.

2008\09\07@031745 by Jan-Erik Soderholm

face picon face
Grant Brown wrote:
> Hi Jan and other's that replied,
>
> Thank you for your feed back. Its a shame that its was so negative.

Just trying to help, which you asked for (and
seemed need).

It was not my intention to be "negative", just trying
to give you my point of view. It was free so it's
totaly up to you what you do with it... :-)

When I started with PIC's, I had seen an experimental
board in the paper Elektor using a 16F84A. This was
8-10 years ago. My first question on Piclist was about
the 16F84A, and the replies got me into more current
processors at once. I never wrote a single source
code line for the 84A...

Why someone would think that the 16F84A is the right
processor *today* escapes me.

Jan-Erik.

2008\09\07@041238 by David Meiklejohn

face
flavicon
face
Grant Brown wrote:
>
> Its interesting given your comments that NSW TAFFE still uses the
> 16F84A to teach MCU programming.

State-run technical colleges aren't exactly dynamic.  It takes a long while
to update course materials, invest in new hardware, ensure that all
instructors are familiar with the new material, and to roll it out
consistently (e.g. assessment) in colleges across the state.

> I also wonder how much industrial equipment is still in use around the
> world that has 16F84A chips in them. Just because something is a bit
> older and slower than the latest u-bueat does not mean it should be
> discarded.

I agree that a lot of older hardware is doing a reliable job in industry.
But it's a different story when it comes to education.  Getting back on
topic, if someone was trying to teach "how to implement a serial port on a
PIC", and they were using a 16F84A, the students would never get to learn
how it's most commonly done in the real world (using a hardware USART
peripheral).  Technical education has to try to keep up with what students
will face when they leave college - always difficult to achieve.


David Meiklejohn
http://www.gooligum.com.au




2008\09\07@042735 by Dario Greggio

face picon face
Byron Jeff wrote:

> For a sample of a SDCC based C application that seems to send morse code via the
> hardware USART, check this code out:
>
> http://homepage3.nifty.com/ARTWEB/pic1.files/sac2.c

did they every hear of "switch()" ? :) or that compiler won't support it...


--
Ciao, Dario

2008\09\07@054615 by Grant Brown

flavicon
face
Hi Jan,

As I have said in other reply's, I did not say that the 16F84A is the
right processor, buts its one that I have and as such I can without
spending any further dollars start to explore the MCU world.

I have been down the track of spending endless hours and dollars setting
up system hardware etc and really not achieving a great deal.

I now prefer to use what is on hand as a starting point and then build
on as required.

20 years of system development and Win 32 programming teaches one a few
gotchas.

I had a look at some "C" bit banged RS232 serial source code. The fact
that its not using library macros and the codes more raw  makes it a bit
easier to trace the logic through.

Kind Regards
Grant Brown



Jan-Erik Soderholm wrote:
{Quote hidden}

--
Kind Regards
Grant Brown

SiteDoc Pty Ltd
mob: 0412 926 995
http://www.sitedoc.com.au
__________________________________________________________________________________________________________
This email message together with any attachments is intended only for the addressee(s) and contains information that may be confidential and/or copyright.  If you are not the intended recipient, please notify the sender by reply email (or telephone SiteDoc Pty Ltd on +61 2 42291185) and immediately delete this email together with any attachments from your computer. If you are the intended recipient, you must not copy, disclose, reproduce or distribute this communication together with any attachments without the authority of SiteDoc Proprietary Limited. No representation is made that this email or any attachments are free of viruses. Virus scanning is recommended and is the responsibility of the recipient. Unless specifically stated by the sender as the views of SiteDoc Proprietary Limited, any views expressed in this message are those of the individual sender, and no responsibility will be borne by SiteDoc Proprietary Limited for its content or outcomes.

2008\09\07@061302 by Forrest W Christian

flavicon
face
While I agree 100% with other's sentiments about the 'F84 being aged and
not where I would start....

Download a copy of MikroC (or MikroBasic or MikroPascal, if either is
more to your liking).  The free version is limited to 2kwords of program
memory.  Since the 'F84 only has 1.75kwords, I don't see this as a
limitation which will affect you.

Also, what are you using to program the 'F84 with?   The reason why I
ask is that you should be able to simply pull the 'F84 off the board and
replace it with a newer pin-compatible chip such as the 'F88 assuming
your programmer is compatible.   This will cost you almost nothing since
you can get 2-3 of pretty much any newer chip from Microchip for free
through their sample program.  

-forrest





2008\09\07@072808 by Wouter van Ooijen

face picon face
> Since the 'F84 only has 1.75kwords,

1k words. 1.75k is in bytes, which is IMHO marketing speak to make a
chip look better.


--

Wouter van Ooijen

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

2008\09\07@081149 by olin piclist

face picon face
David Meiklejohn wrote:
>> Its interesting given your comments that NSW TAFFE still uses the
>> 16F84A to teach MCU programming.
>
> State-run technical colleges aren't exactly dynamic.  It takes a long
> while to update course materials, invest in new hardware, ensure that
> all instructors are familiar with the new material, and to roll it out
> consistently (e.g. assessment) in colleges across the state.

I've also noticed that as a group, teachers seem to be rather reluctant to
learn new things.


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

2008\09\07@081916 by olin piclist

face picon face
Grant Brown wrote:
> As I have said in other reply's, I did not say that the 16F84A is the
> right processor, buts its one that I have and as such I can without
> spending any further dollars start to explore the MCU world.

Get a few free samples of the 16F88 or one of the more modern PICs that are
pin-compatible with the archair 16F84 and inlude a UART.  Experiment with
the basic PIC 16 architecture with the '84 until the samples arrive.  There
will be lots to learn to get the first LED to blink.  Just getting used to
MPASM/MPLIB/MPLINK and debugging in MPLAB is a necessary step that can be
done pretty much on any chip, including the dinosaurs you have.

By the time you're ready for dealing with the UART, you'll have the samples
with the hardware UART.

> I had a look at some "C" bit banged RS232 serial source code.

Forget about C for starters.  Do the LED blinking and the first UART code in
assembler.  Once you have a basic working knowledge of that, then you can
start playing with C.


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

2008\09\07@221126 by Byron Jeff

flavicon
face
On Sun, Sep 07, 2008 at 02:37:45AM -0400, Grant Brown wrote:
> Hi Jan and other's that replied,
>
> Thank you for your feed back. Its a shame that its was so negative.

Grant,

I don't think that it was negative. It was hard won group experience that
members of the list were passing on to you.

> Whist the PIC16F84A maybe old its not completely useless.

I still have one working in a project I installed 10 years ago. I certainly
isn't useless.

> Its interesting given your comments that NSW TAFFE still uses the 16F84A
> to teach MCU programming. Its actually where I got the test board from
> as I have a friend that works in that department.

As Olin pointed out educational institutions often have significant
investments of time and money in their existing infrastrcture.

But as an instructor myself I would point out for the same reasons that
it's a poor starting point.

> I also wonder how much industrial equipment is still in use around the
> world that has 16F84A chips in them. Just because something is a bit
> older and slower than the latest u-bueat does not mean it should be
> discarded.

The key phrase is "Do not use for new designs." When the 16F84A was a cost
effective fit for those applications at the time, they were used. But now
there are better fits even for those applications and new applications.

The problem isn't that it's older or slower. The problem is that the part
has extremely limited peripheral support. A single timer, no USART, A2D,
comparitor, PWM, or compare/capture forces designers to use software and/or
support hardware for many many common embedded applications tasks,
including the one that you asked about initially.

A 16F84A that you have laying around is probably good for a single (or very
limited) application. The project I referred to above was simply a delay
for my basement lights so that they turned off 90 seconds after the door
closes. Pretty trivial to implement.

But when you are juggling multiple tasks and interfaces as many projects
do, it's a lot simpler to have hardware assistance.

> Over many years now I have tought a large number of appretices and that
> has shown me that one does not teach and or help new comers by being
> negative.

But you also don't teach by being unrealistic either. You teach apprentices
better when they understand that picking the best tool for a job will get
the job done better and faster.

There is utility in teaching the underlaying basics of how a task works. I
have no problem with that. The problem is people generally have a syndrome
that one of my colleagues called "love what you learn syndrome." So if you
teach an older technique that no longer common practice, often students
will use that technique precisely because that is what they were taught.

One technique I use is to show an older approach to solving a problem
precisely to illustrate why newer solutions became available. In your case
shoing bit banging has some utility to illustrate the problems you get when
you try to integrate it with multiple other tasks, especially with a chip
that only has a single timer for example.

All of the peripherals we have referred to in the newer chips are pretty
much set and forget. Set up the USART, and drop in a character to transmit,
or wait for a received character to receive. No need to track individual
bits or timing half bit cells in order to send or receive.

> Anyway thank you for your assistance and I will take on-board your advice.

That's good. It will help you in the long run.

BAJ
{Quote hidden}

> -

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