Searching \ for '[PIC]: Newbie PICster' 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 PICster'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Newbie PICster'
2000\12\08@080740 by Duane Brantley

flavicon
face
Hello all,

This is my first attempt at using a PIC. I thought I'd start out simple and
grow from there.  I tried writing a small program in MPASM to send the word
"Hello" out the USART on a F877, but with no luck.  I was wondering if
someone could take a look at it, and tell me what I'm doing wrong.

Cheers,
Duane


;========(HELLO.ASM)========================================================
=======(12/4/00)=====
;This program will display the text "Hello" on the LCD.
;---------------------------------------------------------------------------
---------------------
       list    p=16f877
       #include <p16f877.inc>
       radix   hex
;---------------------------------------------------------------------------
---------------------
;       cpu equates  (memory map)
;-------MAIN----------------------------------------------------------------
---------------------

               org     0x000
SETBAUD:        bcf     STATUS,RP1      ;
               bSf     STATUS,RP0      ; Bank 1
               movlw   0x81            ; Set Baud Rate to 9600
               movwf   SPBRG           ;
               movlw   0x26            ; 8-bit transmit, transmitter
enabled
               movwf   TXSTA           ;
               bcf     TRISC,6         ; set RC6 as output
               bcf     PIE1,4          ; clear interrupt bit (TXIE)
               bcf     STATUS,RP0      ; Bank 0
               movlw   0x80            ;
               movwf   RCSTA           ; Serial port enabled
               goto    HELLO

SERIAL: btfss   PIR1,4          ; wait for bit 4 = 1 (showing TXREG empty)
               goto    SERIAL          ;  <== I get stuck in a loop here
               nop
               movwf   TXREG
               return

HELLO:          movlw   'H'             ; Send out 'Hello'
               movwf   TXREG
               call    SERIAL
               movlw   'e'
               movwf   TXREG
               call    SERIAL
               movlw   'l'
               movwf   TXREG
               call    SERIAL
               movlw   'l'
               movwf   TXREG
               call    SERIAL
               movlw   'o'
               movwf   TXREG
               end




;---------------------------------------------------------------------------
---------------------

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


2000\12\08@090604 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

You have to set the SPEN bit (bit 7 of register RCSTA) to enable the serial
port.  The datasheet also states that bits TRISC6 and TRISC7 have to be set,
i.e. configured as inputs.  However ISTR there was some quite heated debate
a while back on the list as to whether this was actualy required.

Regards

Mike

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


2000\12\08@091022 by Shawn Yates

flavicon
face
Do PIC's allow letters as literals?  What value does it use for them Ascii
standard?

-----Original Message-----
From: Michael Rigby-Jones [mrjonesspamKILLspamNORTELNETWORKS.COM]
Sent: Friday, December 08, 2000 9:04 AM
To: .....PICLISTKILLspamspam.....MITVMA.MIT.EDU
Subject: Re: [PIC]: Newbie PICster


{Quote hidden}

You have to set the SPEN bit (bit 7 of register RCSTA) to enable the serial
port.  The datasheet also states that bits TRISC6 and TRISC7 have to be set,
i.e. configured as inputs.  However ISTR there was some quite heated debate
a while back on the list as to whether this was actualy required.

Regards

Mike

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

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


2000\12\08@091815 by Wynn Rostek

flavicon
face
----- Original Message -----
From: Duane Brantley <@spam@Duane.BrantleyKILLspamspamGENBAND.COM>
To: <KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU>
Sent: Friday, December 08, 2000 8:08 AM
Subject: [PIC]: Newbie PICster


> Hello all,
>
> This is my first attempt at using a PIC. I thought I'd start out simple
and
> grow from there.  I tried writing a small program in MPASM to send the
word
> "Hello" out the USART on a F877, but with no luck.  I was wondering if
> someone could take a look at it, and tell me what I'm doing wrong.
>
> Cheers,
> Duane
>


Duane,


From Section 10.2 of the 'F877 data sheet:

NOTE:

Flag bit TXIF is set when enable bit TXEN is set. TXIF is cleared by loading
TXREG.

Also from section 10.2,

Once the TXREG register transfers the data to the TSR register, the TXREG
register is empty and flag bit TXIF (PIR1 <4>)  is set.

I think you want to change SERIAL: btfss PIR1,4
to SERIAL: btfsc PIR1,4

Wynn Rostek

(It's too early in the morning for me to be sure just by reading.)

>
> SERIAL: btfss   PIR1,4          ; wait for bit 4 = 1 (showing TXREG empty)
>                 goto    SERIAL          ;  <== I get stuck in a loop here
>                 nop
>                 movwf   TXREG
>                 return
>

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


2000\12\08@092646 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

The original logic is correct AFAIK.  The intent is to wait until the TXREG
buffer is empty and so can accept another byte.  This means looping until
the TXIF flag is set.

Mike

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


2000\12\08@094519 by Scott Dattalo

face
flavicon
face
On Fri, 8 Dec 2000, Duane Brantley wrote:

> Hello all,
>
> This is my first attempt at using a PIC. I thought I'd start out simple and
> grow from there.  I tried writing a small program in MPASM to send the word
> "Hello" out the USART on a F877, but with no luck.  I was wondering if
> someone could take a look at it, and tell me what I'm doing wrong.

Are you the same Duane that used to work at NI? If so Hi. If not, well, still
Hi.

Scott

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


2000\12\08@115740 by Olin Lathrop

face picon face
> This is my first attempt at using a PIC. I thought I'd start out simple
and
> grow from there.  I tried writing a small program in MPASM to send the
word
> "Hello" out the USART on a F877, but with no luck.  I was wondering if
> someone could take a look at it, and tell me what I'm doing wrong.

In general you need to be more concious of the register bank setting.  I
noticed you did set bank 1 at one point, but you need to make sure the bank
is correct for all the SFRs except the few that are mapped accross banks
(like INTCON, INDF, etc).

I like to do this with macros that set the bank approriately given a memory
address.  That eliminates errors manually setting RP0 and RP1.


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

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


2000\12\08@130429 by Olin Lathrop

face picon face
> Do PIC's allow letters as literals?  What value does it use for them Ascii
> standard?

Yes, 7 bit ASCII with the high bit 0.


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

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


2000\12\08@133212 by Duane Brantley

flavicon
face
Thanks for all the help.  I compile all the replies, and give them a try
tonight when I have time.

Thanks again,

Duane

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


2000\12\08@160337 by Wynn Rostek

flavicon
face
Duane,
Set SPEN, and Set TRISC = 0x80, you'll be fine unless there are other
problems. (hardware or interrupts)

(I'm fully awake now.)

Wynn

> Thanks for all the help.  I compile all the replies, and give them a try
> tonight when I have time.
>
> Thanks again,
>
> Duane

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


2000\12\08@161547 by Dominic Martin

flavicon
face
I am not 100% sure about it but i think you are not going back to bank0
after you change the serial setting.
I am not a expert with this pic but i have design my one rs232 transmiter on
a PIC16F84.

I hope this will help.


{Original Message removed}

2000\12\08@220405 by Stephen

flavicon
face
> I am not 100% sure about it but i think you are not going back to bank0
> after you change the serial setting.
> I am not a expert with this pic but i have design my one rs232
> transmiter on
> a PIC16F84.

would you mind posting the source for that? i've been looking for a routine
for that but have not been able to find a good one.

---
This mail sent through Motionlink Webmail
http://www.motionlink.net/

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


2000\12\09@080448 by dr. Imre Bartfai

flavicon
face
Hi,

IMHO there are superfluous statements below. I marked them with ;;; at the
front.
Regards:
Imre

On Fri, 8 Dec 2000, Duane Brantley wrote:

{Quote hidden}

;;;               movwf   TXREG
>                 call    SERIAL
>                 movlw   'e'
;;;               movwf   TXREG
>                 call    SERIAL
>                 movlw   'l'
;;;               movwf   TXREG
>                 call    SERIAL
>                 movlw   'l'
;;;               movwf   TXREG
>                 call    SERIAL
>                 movlw   'o'
;;;               movwf   TXREG
{Quote hidden}

--
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 2000 , 2001 only
- Today
- New search...