Searching \ for '[PIC] : New to PIC16F877' 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/devices.htm?key=16F
Search entire site for: ': New to PIC16F877'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] : New to PIC16F877'
2001\01\31@004359 by Jose S. Samonte Jr.

picon face
Good day to all!
I'm really new to PIC programming,
and what I have in my hands now is a PIC16F877.
Please help me, anyone?
Sirs, how do I initialize the ports for digital I/O?
What should I take care of, ADCON0 or ADCON1?
I'm kinda confused with the datasheet.
I also want to learn sirs how to use the USART of
the PIC16F877. Would somebody be willing to lend me a source code
which uses the USART?
Thank you very much and God Bless.

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\01\31@012848 by Tony Nixon

flavicon
picon face
"Jose S. Samonte Jr." wrote:
{Quote hidden}

       Title "Your Program"
;
       list P = 16F877
;
       include "P16f877.inc"
;
; ------------------
; CONFIGURATION FUSE
; ------------------
;
       __CONFIG _CP_OFF & _WRT_ENABLE_ON & _RC_OSC & _WDT_ON & _PWRTE_OFF &
_BODEN_ON & _LVP_ON & _CPD_OFF & _DEBUG_OFF
;
; CRYSTAL SPEED = 4000000Hz
;
       CBLOCK 0x20

dataL

       ENDC
;
; -------------
; PROGRAM START
; -------------
;
       org 0x0000              ; startup = 0000h
;
Start   movlw 0x00              ; setup ports
       movwf PORTA
       movlw 0x00
       movwf PORTB
       movlw 0x40
       movwf PORTC
       movlw 0x00
       movwf PORTD
       movlw 0x00
       movwf PORTE
       bsf STATUS,RP0          ; RAM Page 1
       movlw 0x00
       movwf TRISA
       movlw 0x00
       movwf TRISB
       movlw 0x80
       movwf TRISC
       movlw 0xFF
       movwf TRISD
       movlw 0xFF
       movwf TRISE
;
; -------------------------
; SET ANALOG/DIGITAL INPUTS
; -------------------------
;
       movlw 0x06              ; all digital
       movwf ADCON1
;
; ------------------------------------
; SET BAUD RATE TO COMMUNICATE WITH PC
; ------------------------------------
; Boot Baud Rate = 19200, No Parity, 1 Stop Bit
;
       movlw 0x0C              ; 19200 baud
       movwf SPBRG
       movlw b'00100100'       ; brgh = high (2)
       movwf TXSTA             ; enable Async Transmission, set brgh
       movlw b'10010000'       ; enable Async Reception
       bcf STATUS,RP0          ; RAM Page 0
       movwf RCSTA
;
; ------------------------------------
; PROVIDE A SETTLING TIME FOR START UP
; ------------------------------------
;
       clrf dataL
settle  decfsz dataL,F
       goto settle
;
       movf RCREG,W
       movf RCREG,W
       movf RCREG,W            ; flush receive buffer

Loop    call Receive            ; wait for a char
       movwf TXREG             ; echo data back to sender
       goto Loop
;
; ----------------------------
; RECEIVE CHARACTER FROM RS232
; ----------------------------
; This routine does not return until a character is received.
;
Receive btfss PIR1,RCIF         ; (5) check for received data
       goto Receive
;
       movf RCREG,W
       return
;
; ------------------------------------
; WAIT UNTIL RS232 IS FINISHED SENDING
; ------------------------------------
;
TransWt bsf STATUS,RP0
WtHere  btfss TXSTA,TRMT                ; (1) transmission is complete if hi
       goto WtHere
;
       clrf STATUS             ; RAM Page 0
       return
;
;
       end

--
Best regards

Tony

mICro's
http://www.picnpoke.com
salesspamKILLspampicnpoke.com

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2001\01\31@025014 by Vasile Surducan

flavicon
face
Thank's Tony !
BTW, can be configured an 877 UART to "scan" PC transmission and to
autoset his baud rate ?
Vasile


On Wed, 31 Jan 2001, Tony Nixon wrote:

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2001\01\31@081801 by Drew Vassallo

picon face
>I'm really new to PIC programming,
>and what I have in my hands now is a PIC16F877.

There's mistake #1.  Try a smaller chip with fewer features/banks.

>Sirs, how do I initialize the ports for digital I/O?

Read the datasheet.

>What should I take care of, ADCON0 or ADCON1?

For what purpose?

>I also want to learn sirs how to use the USART of
>the PIC16F877. Would somebody be willing to lend me a source code
>which uses the USART?

You're "really new to PIC programming" and you're worried about how to use
the USART?  Jose, try building up to this with simpler projects.  It's
obvious that you do not really understand the basics, so you should leave
the more difficult features until you have a firm hold on easier features.
The PICLIST has numerous projects/code examples/tutorials for new users.
Read through them for a few weeks and your questions will be answered.

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\01\31@090413 by Olin Lathrop

face picon face
> Sirs, how do I initialize the ports for digital I/O?
> What should I take care of, ADCON0 or ADCON1?

The 16F877 wakes up with the A/D pins set to analog.  You have to configure
them as digital I/O if you want to use them that way.

> I also want to learn sirs how to use the USART of
> the PIC16F877.

The data sheet is quite good for this.  If you still have problems, you can
probably find some app notes on the Microchip web site.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, spamBeGoneolinspamBeGonespamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu


2001\01\31@111718 by Dan Michaels

flavicon
face
At 08:18 AM 1/31/01 -0500, you wrote:
>>I'm really new to PIC programming,
>>and what I have in my hands now is a PIC16F877.
>
>There's mistake #1.  Try a smaller chip with fewer features/banks.
...........
>You're "really new to PIC programming" and you're worried about how to use
>the USART?  Jose, try building up to this with simpler projects.  It's
>obvious that you do not really understand the basics, so you should leave
>the more difficult features until you have a firm hold on easier features.


Good advice.

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu


2001\01\31@113542 by Kevin Blain

flavicon
face
Well done Tony. You appear to have answered his request in a helpful manner.
I am sure he will appreciate it.

Regards, Kevin

{Original Message removed}

2001\01\31@165108 by Tony Nixon

flavicon
picon face
Vasile Surducan wrote:
>
> Thank's Tony !
> BTW, can be configured an 877 UART to "scan" PC transmission and to
> autoset his baud rate ?
> Vasile

No doubt it can, but I haven't played in that area yet.

--
Best regards

Tony

mICro's
http://www.picnpoke.com
salesEraseMEspam.....picnpoke.com

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2001\01\31@173930 by Bob Ammerman

picon face
> > BTW, can be configured an 877 UART to "scan" PC transmission and to
> > autoset his baud rate ?
> > Vasile

Not in any automatic way.

A simple way, if the PC is periodically  trying to send data is to just try
different baud rates until one works (works == intelligible data seen).

This won't work very well if the PC is transmitting continuously, however.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamEraseMEmitvma.mit.edu


2001\01\31@195946 by Bill Westfield

face picon face
> > BTW, can be configured an 877 UART to "scan" PC transmission and to
> > autoset his baud rate ?

>> This won't work very well if the PC is transmitting continuously...

Syncing a uart to a continuous async data stream is an intersting problem.
A sort-of-obvious answer is to "shift" where you think the start bit might
be each time you see several consecutive framing errors (no stop bit.) We
recently discovered that not all (commercial) UARTS do this, however!
Indeed, we're heavilly using a chip that has the annoying feature that it
will LOSE sync with a stream if you give it a "receiver start" command while
the receiver is already started (and synced) with a stream!  (Fortunately,
this uart has downloadable microcode, and the vendor is fixing things (Damn,
that was a good idea I had!)

If you don't know either the bitrate OR where the start bit is, you'd have
a really interesting time - you'd almost be better off with a software uart.
(scan for "narrowest bit" to get speed, use start/stop bit detection to sync
with correct character positions.)

BillW

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu


2001\01\31@202453 by Tony Nixon

flavicon
picon face
William Chops Westfield wrote:

> If you don't know either the bitrate OR where the start bit is, you'd have
> a really interesting time - you'd almost be better off with a software uart.
> (scan for "narrowest bit" to get speed, use start/stop bit detection to sync
> with correct character positions.)

Perhaps that's the key.

Have the software scan for the bit width you mention and when it is
happy, set the UART baud rate to suit.

To establish comms, the PC or whatever can send out a stream of 'X'
chars (?) until told to stop, or for a fixed duration.

The receiver scans the bit widths to decide on a baud rate and sets the
UART.

If it detects all bytes are 'X' then ACK to PC that it is online.

--
Best regards

Tony

mICro's
http://www.picnpoke.com
RemoveMEsalesTakeThisOuTspamspampicnpoke.com

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspamspamspamBeGonemitvma.mit.edu



'[PIC] : New to PIC16F877'
2001\02\01@053428 by Simon Nield
flavicon
face
bob:
>different baud rates until one works (works == intelligible data seen).

might checking the framing error bit not work a bit better here ?


every time you get an RX interrupt check the framing error bit, if it is set then reset the receiver
and increment some counter.
if that counter reaches some magic nubmer then try another baud rate (better to go up or down ?)



not sure if that would work, but it feels about right.


regards,
Simon

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\01@094805 by Bob Ammerman

picon face
> bob:
> >different baud rates until one works (works == intelligible data seen).
>
> might checking the framing error bit not work a bit better here ?

That would be part of 'intelligible', but you'll not always get framing
errors, depending on thebit patterns and relative baud rates.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\01@175327 by rich+piclist

flavicon
face
> To establish comms, the PC or whatever can send out a stream of 'X'
> chars (?) until told to stop, or for a fixed duration.

You can autobaud with a PC with a single FF sent at whatever baud rate
which the PC tries to receive at 115200. The sender's start bit is
stretched into 'n' bits, so the actual rate is 115200/n. i.e. if you
receive:

0111111111 (FF) = FF sent at 115200

0011111111 (FE) = FF sent at 57600

0001111111 (FC) = 38400

0000001111 (E0) = 19200

0000000000 0011111111 (00 FE) = 9600

0000000000 0000000000 0000111111 (00 00 F8) = 4800

etc. But for rates 9600 and below use the number of leading zero BYTES,
baud clock error makes the actual end value jittery. Useful if device baud
rate changes on the fly, as you can simply preface EVERY message with 0xFF
and autobaud each time.

Presumably the basic technique is applicable to any uart.

== Rich

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\02\02@041810 by Vasile Surducan

flavicon
face
On Wed, 31 Jan 2001, Dan Michaels wrote:

> At 08:18 AM 1/31/01 -0500, you wrote:
> >>I'm really new to PIC programming,
> >>and what I have in my hands now is a PIC16F877.
> >
> >There's mistake #1.  Try a smaller chip with fewer features/banks.
> ...........
>
> Good advice.
>

 Sorry guy's but I'm not agree with you !
877 it's excellent for beginners. Who force the beginner to work more than
bank1 ? After you've write such excellent tools like Wloader-Wouter van
Ooijen, Romzap- Tony Nixon, Bootloader-Rick Farmer and many others now you
recommend a smaller chip!
Maybe an UV erasable then, to cry waiting to erase and program it!
Huh, what kind of specialists are you? { joke }

By, Vasile
http://www.geocities.com/vsurducan/vasile.htm

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


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