EmbeddedRelated.com
Forums

16F628

Started by Unknown November 17, 2004
In a message dated 11/18/2004 10:01:47 AM Eastern Standard Time, s...@xcprod.com writes:


bit-banging means that the USART is emulated by a piece of software. The
software has to turn the output on and off the same way that the hardware
USART would. Not only that, but it also has to read the input pin the same
way. The software cannot do this by just turning the output on and off in
quick succession, it has to generate accurate bit lengths when outputting
and filter out noise when inputting. This requires accurate timing and
consequently restricts what the PIC is able to do at the same time and the
highest speed that the emulated USART can operate at. All in all, hardware
USARTs are better than software emulated USARTs and you should try to use
the hardware one if possible.


I put a 10K pull up on A.4, wrote:

so  con  PortA.4
serout2 so, baud, ["ABC", "A"]

and on my Stamp:

serin si, baud, [(WAIT("ABC"), com]

and it appears to be working just fine.

Sid









>
> I put a 10K pull up on A.4, wrote:
>
> so con PortA.4
> serout2 so, baud, ["ABC", "A"]
>
> and on my Stamp:
>
> serin si, baud, [(WAIT("ABC"), com]
>
> and it appears to be working just fine.
>
> Sid

Remember back a few messages when I asked about your software
platform? If you are using one of the packages that includes bit-
banging then you don't have to code it yourself. Some languages
include the feature so they can work with devices that don't have a
USART.

As a group, we can save a lot of bandwidth by nailing down the
language platform first.


In a message dated 11/18/2004 10:41:23 AM Eastern Standard Time, r...@pacbell.net writes:


As a group, we can save a lot of bandwidth by nailing down the
language platform first.


Sorry about the platform issue.  I thought when I wrote "serout2"  that it was apparent I was using PBasic.  I'll be more precise in the future.

Sid




On the PicList, we tend to operate closer
to the PIC than the Stamp keywords.

However, "SEROUT2 ...." *is* a bit-bang
serial command. There's two ways to do RS-232
I/O. One way is to use a hardware UART of some
kind. This is a piece of hardware which knows
about the RS232 timings, logic levels, etc.

The other way is to use a microprocessor to
toggle an I/O pin in the appropriate way, with
appropriate timing, to generate the RS232 signal.
This is called 'bit-banging', because the processor
'bangs' each 'bit' out the pin.

Using SEROUT hides all this complexity from you.
The Basic compiler generates the appropriate
bit-banging code for you when you use that keyword.

You can bit-bang out any I/O pin. Some PICS have
an on-PIC hardware UART. This UART is hard-wired
to two of the PIC pins (one for output, one for input).
Thus to use the hardware UART you must use a particular
pin off the PIC. --- In , Newzed@a... wrote:
> In a message dated 11/17/2004 9:22:00 PM Eastern Standard Time,
> rstofer@p... writes: > > There is no reason you can't use a different pin but, like the
> > Stamp, it will require bit-banging. If you want to use the
USART,
> > you will have to use the pins it is wired to.
> >
>
> I'm not sure I understand what you mean by bit-banging. If I put
a pullup on
> A.4, then write:
>
> dat con {prtA.4
> serout2 dat, baud, ["A"]
>
> Isn't that enough?
>
> Thanks
>
> Sid



Hello. I'm using PicBasic Pro and a PIC16F628. I've been reading up on the DEBUG command, and can't seem to get it to work. I am using Hyper Terminal.
 
here is my code:
 
' open the file with the definitions that we need:
INCLUDE "modedefs.bas"
' Set Debug pin port
define osc 20
DEFINE DEBUG_REG PORTB
' Set Debug pin BIT (RB0 in this case)
DEFINE DEBUG_BIT 0
' Set Debug baud rate
DEFINE DEBUG_BAUD 9600
' Set Debug mode: 0 = true, 1 = inverted
DEFINE DEBUG_MODE 1
       
' set variables:
inData VAR BYTE
       
inData = 0
Pause 500
main:
     ' listen for 100 milliseconds for incoming data.
     ' if there is none, go to the "onward" label:
     Serin2 PORTA.0, 84, 100, onward, [inData]
     Debug "indata", inData
goto main
onward: 
    debug "no data"
goto main
 
This is an example I found on the web and changed to fit my PIC.
 
http://fargo.itp.tsoa.nyu.edu/~tigoe/pcomp/examples/pic-debug-pbpro.shtml
 
The above is the website I found.
In the description pin 3 on the DB9 connector is not connected, but in the picture, it is connected to the TX pin (The picture looks like an '877).
Can anyone direct me to a more informative site? I've been trying to get this to work for days. It seems like an easy, trivial matter that most of you could help me with in your sleep. I am relatively  new to PICs in general (moving from BS2). If I can figure this one out, I will not need a BS2 for anything anymore.
 
note: I have been able to bit-bang data from the PIC to my BS2, then display that in Hyper Terminal, but it still depends on the BS2.
 
Thanks to all,
John Baker

N...@aol.com wrote:
In a message dated 11/18/2004 10:41:23 AM Eastern Standard Time, r...@pacbell.net writes:


As a group, we can save a lot of bandwidth by nailing down the
language platform first.


Sorry about the platform issue.  I thought when I wrote "serout2"  that it was apparent I was using PBasic.  I'll be more precise in the future.

Sid


to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

__________________________________________________




Have you ever been able to talk to HyperTerminal from the PIC? If
not, it may be because you aren't using the right voltage levels.
The PIC puts out a 5V signal but that may not be enough for the PC.

Ordinarily an RS232 level converter is used to change between 5V
levels and +-12V RS232 levels (not that these levels are always
achieved). One dongle that works well is: http://www.al-
williams.com/rs1.htm

My personal preference is the MAX233 device as it doesn't require
external capacitors. Another choice is the MAX232 device - it does
require capacitors.

That schematic you referenced will work only if the PC will accept a
logic level coming from the PIC - many (probably most) won't. As to
the 22k resistor - well, that isn't guaranteed to reduce the voltage
to PIC levels either.

I'm not sure why you can talk to the Stamp - I've never used one.

Just guessing, I haven't used PicBasic PRO either. --- In , John Baker <johnbaker_erie_pa@y...>
wrote:
> Hello. I'm using PicBasic Pro and a PIC16F628. I've been reading
up on the DEBUG command, and can't seem to get it to work. I am
using Hyper Terminal.
>
> here is my code:
>
> ' open the file with the definitions that we need:
> INCLUDE "modedefs.bas"
> ' Set Debug pin port
> define osc 20
> DEFINE DEBUG_REG PORTB
> ' Set Debug pin BIT (RB0 in this case)
> DEFINE DEBUG_BIT 0
> ' Set Debug baud rate
> DEFINE DEBUG_BAUD 9600
> ' Set Debug mode: 0 = true, 1 = inverted
> DEFINE DEBUG_MODE 1
>
> ' set variables:
> inData VAR BYTE
>
> inData = 0
> Pause 500
> main:
> ' listen for 100 milliseconds for incoming data.
> ' if there is none, go to the "onward" label:
> Serin2 PORTA.0, 84, 100, onward, [inData]
> Debug "indata", inData
> goto main
> onward:
> debug "no data"
> goto main
>
> This is an example I found on the web and changed to fit my PIC.
>
> http://fargo.itp.tsoa.nyu.edu/~tigoe/pcomp/examples/pic-debug-
pbpro.shtml
>
> The above is the website I found.
> In the description pin 3 on the DB9 connector is not connected,
but in the picture, it is connected to the TX pin (The picture looks
like an '877).
> Can anyone direct me to a more informative site? I've been trying
to get this to work for days. It seems like an easy, trivial matter
that most of you could help me with in your sleep. I am relatively
new to PICs in general (moving from BS2). If I can figure this one
out, I will not need a BS2 for anything anymore.
>
> note: I have been able to bit-bang data from the PIC to my BS2,
then display that in Hyper Terminal, but it still depends on the BS2.
>
> Thanks to all,
> John Baker
>
> Newzed@a... wrote:
> In a message dated 11/18/2004 10:41:23 AM Eastern Standard Time,
rstofer@p... writes:
>
>
> As a group, we can save a lot of bandwidth by nailing down the
> language platform first. > Sorry about the platform issue. I thought when I wrote "serout2"
that it was apparent I was using PBasic. I'll be more precise in
the future.
>
> Sid
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions
>
>
> ---------------------------------
> Yahoo! Groups Links
>
> To > __________________________________________________
>




I have a few RS232 chips laying around. I'll try this:
http://www.electronic-engineering.ch/microchip/projects/rs_test/RS232-Interface.pdf
 
I see here that the handshake lines are not needed for
his routines...
http://www.electronic-engineering.ch/microchip/projects/rs_test/rs_test.html
 
I play around awhile more.
Thanks for the link.
 
Regards,
John

rtstofer <r...@pacbell.net> wrote:


Have you ever been able to talk to HyperTerminal from the PIC? If
not, it may be because you aren't using the right voltage levels. 
The PIC puts out a 5V signal but that may not be enough for the PC.

Ordinarily an RS232 level converter is used to change between 5V
levels and +-12V RS232 levels (not that these levels are always
achieved).  One dongle that works well is: http://www.al-
williams.com/rs1.htm

My personal preference is the MAX233 device as it doesn't require
external capacitors.  Another choice is the MAX232 device - it does
require capacitors.

That schematic you referenced will work only if the PC will accept a
logic level coming from the PIC - many (probably most) won't.  As to
the 22k resistor - well, that isn't guaranteed to reduce the voltage
to PIC levels either.

I'm not sure why you can talk to the Stamp - I've never used one.

Just guessing, I haven't used PicBasic PRO either.--- In p...@yahoogroups.com, John Baker <johnbaker_erie_pa@y...>
wrote:
> Hello. I'm using PicBasic Pro and a PIC16F628. I've been reading
up on the DEBUG command, and can't seem to get it to work. I am
using Hyper Terminal.

> here is my code:

> ' open the file with the definitions that we need:
> INCLUDE "modedefs.bas"
> ' Set Debug pin port
> define osc 20
> DEFINE DEBUG_REG PORTB
> ' Set Debug pin BIT (RB0 in this case)
> DEFINE DEBUG_BIT 0
> ' Set Debug baud rate
> DEFINE DEBUG_BAUD 9600
> ' Set Debug mode: 0 = true, 1 = inverted
> DEFINE DEBUG_MODE 1
>       
> ' set variables:
> inData VAR BYTE
>       
> inData = 0
> Pause 500
> main:
>      ' listen for 100 milliseconds for incoming data.
>      ' if there is none, go to the "onward" label:
>      Serin2 PORTA.0, 84, 100, onward, [inData]
>      Debug "indata", inData
> goto main
> onward:
>     debug "no data"
> goto main

> This is an example I found on the web and changed to fit my PIC.

> http://fargo.itp.tsoa.nyu.edu/~tigoe/pcomp/examples/pic-debug-
pbpro.shtml

> The above is the website I found.
> In the description pin 3 on the DB9 connector is not connected,
but in the picture, it is connected to the TX pin (The picture looks
like an '877).
> Can anyone direct me to a more informative site? I've been trying
to get this to work for days. It seems like an easy, trivial matter
that most of you could help me with in your sleep. I am relatively 
new to PICs in general (moving from BS2). If I can figure this one
out, I will not need a BS2 for anything anymore.

> note: I have been able to bit-bang data from the PIC to my BS2,
then display that in Hyper Terminal, but it still depends on the BS2.

> Thanks to all,
> John Baker
>
> Newzed@a... wrote:
> In a message dated 11/18/2004 10:41:23 AM Eastern Standard Time,
rstofer@p... writes:> As a group, we can save a lot of bandwidth by nailing down the
> language platform first.> Sorry about the platform issue.  I thought when I wrote "serout2" 
that it was apparent I was using PBasic.  I'll be more precise in
the future.
>
> Sid
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions> ---------------------------------
> Yahoo! Groups Links
>
>    To > __________________________________________________
> /


to unsubscribe, go to http://www.yahoogroups.com and follow the instructions




----- Original Message -----
From: John Baker
To:
Sent: Saturday, November 20, 2004 10:46 AM
Subject: Re: [piclist] Re: 16F628-Simiar I have a few RS232 chips laying around. I'll try this:
http://www.electronic-engineering.ch/microchip/projects/rs_test/RS232-Interface.pdf

I see here that the handshake lines are not needed for
his routines...
http://www.electronic-engineering.ch/microchip/projects/rs_test/rs_test.html

If you are connecting it to a PC you will need to disable handshaking for
the comms software you are using, or fudge it by wiring the signals on the
connector so that they are enabled.

Leon
--
Leon Heller, G1HSM
http://webspace.webring.com/people/jl/leon_heller/
http://www.kasamba.com/viewExpert.asp?conMemID5725&Catid11&banID!00


In a message dated 11/20/2004 2:37:22 AM Eastern Standard Time, j...@yahoo.com writes:


Hello. I'm using PicBasic Pro and a PIC16F628. I've been reading up on the DEBUG command, and can't seem to get it to work. I am using Hyper Terminal.



For a starter, change INCLUDE to "bs2defs.bas"

You specified mode 1 (inverted) but your baud rate is 84 (true).  Change your baud rate to 16468.

Use serout2 16 instead of debug.  It works better.  I have been using Hyper for years with great success.

Sid


In a message dated 11/20/2004 2:37:22 AM Eastern Standard Time, j...@yahoo.com writes:


Hello. I'm using PicBasic Pro and a PIC16F628. I've been reading up on the DEBUG command, and can't seem to get it to work. I am using Hyper Terminal


P.S.  If you have trouble with Hyper, you can use the Stamp debug screen.  It works just as well.

Sid