Searching \ for '[PIC]: Serial Port and using remaining PortB bits?' 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=serial
Search entire site for: 'Serial Port and using remaining PortB bits?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Serial Port and using remaining PortB bits?'
2003\04\01@213759 by Charles Rice

picon face
Heyas,

To get myself accustomed to mcu programming I am trying to set up a stoplight style program.
I am using the onboard USART and can get chars transmitted and received in hyperterminal. But I can't
get the LEDs I attached to PortB bits 0, 1, and 2 to light up.

Does the use of PortB as the serial comm port somehow make the other bits on that port unusable?

I've pasted my code below, I checked it a couple times for errors but it's hard to set up a good test because of the need to go through the USART. MPSIM doesn't have a way to set up stimulus files to do this afaik.

Thanks a bunch
// ===== Code Below =====
; Hardware Notes: PIC16F876 @ 4Mhz
;
; _MCLR pulled up through 10k-ohm
; RC6 - Serial Transmit Pin
; RC7 - Serial Receive Pin
;
; v1.0

LIST P=16F876, R=DEC
INCLUDE "p16F876.inc"
 CBLOCK 0x020            ; Var not used in this incarnation, was used previously to
SerTemp                      ; store the serial value to work with all 3 lights.
ENDC
 __CONFIG _CP_OFF & _HS_OSC & _PWRTE_ON & _WDT_OFF & _BODEN_ON
; Mainline

org 0
 bcf PORTB, 0   ; PortB 0, off (Red)
bcf PORTB, 1   ; PortB 1, off (Yellow)
bcf PORTB, 2   ; PortB 2, off (Green)
 bsf STATUS, RP0  ; Enable the Serial Port
movlw (1 << TXEN)  ; Enable Serial Transmission
movwf TXSTA ^ 0x080
movlw 51    ; Serial Port running at 1200baud
movwf SPBRG ^ 0x080
 bsf TRISB ^ 0x080, 0 ; Set PortB 0.1.2 to output
bsf TRISB ^ 0x080, 1
bsf TRISB ^ 0x080, 2
 bcf STATUS, RP0
movlw (1 << SPEN) | (1 << CREN)
movwf RCSTA   ; Enable Serial I/O
Loop
btfss PIR1, RCIF  ; Wait for rx character set
 goto Loop    ; Nothing there
movf RCREG, 0   ; Get rx character
bcf PIR1, RCIF   ; Clear the Character Present Flag
 ; Check the rx char against R, Y, G to set indicators
;movwf SerTemp
;sublw 'R'
;BTFSS STATUS, Z
; call GORED
;movf SerTemp, 0
;movwf SerTemp
;sublw 'Y'
;BTFSS STATUS, Z
; call GOYEL
;movf SerTemp, 0
;movwf SerTemp
;sublw 'G'
;BTFSS STATUS, Z
; call GOGRN
;
 bsf PORTB, 0        ; Can I set the bits on at all?
bsf PORTB, 1
 XORWF 'R', w
BTFSS STATUS, Z
 ;call GORED        ; Didn't work this way, trying to set it explicitly below
 bsf PORTB, 0
 movwf TXREG        ; Transmit char for error checking
 goto Loop
 ; Subroutines
GORED:
bsf PORTB, 0
bcf PORTB, 1
bcf PORTB, 2
goto Loop
return
GOYEL:
bcf PORTB, 0
bsf PORTB, 1
bcf PORTB, 2
goto Loop
return
GOGRN:
bcf PORTB, 0
bcf PORTB, 1
bsf PORTB, 2
goto Loop
return

end

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

2003\04\01@222914 by Rick Regan

picon face
> bsf TRISB ^ 0x080, 0 ; Set PortB 0.1.2 to output
> bsf TRISB ^ 0x080, 1
> bsf TRISB ^ 0x080, 2

The comment says output, but you are setting them
to input.


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

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

2003\04\01@230448 by Russell C. Hay

flavicon
face
I'm probably missing something completely obvious, but why are you XOR'ing
TRISB with 0x080?  I've had no problem just using TRISB without XOR'ing it
(after switching to bank 1)  Just curious ...

{Original Message removed}

2003\04\01@234052 by Banjo Spam

picon face
Yes, it *is* completely obvious!! :-) Just kidding,
but we all (together) did review this within the last
few weeks.

XOR'ing a register value with 0x080 gets rid of Error
302 (I think that is the number). It also has the side
effect of giving an error if the register is not in
Bank 1.

There are various and sundry ways of getting rid of
the "not in Bank 0" error. Each with their own
advantages, disadvantages, adherents, and detractors.

Hope this helps.

--- "Russell C. Hay" <rhayspamKILLspamZONEPHOTOGRAPHY.COM> wrote:
> I'm probably missing something completely obvious,
> but why are you XOR'ing
> TRISB with 0x080?  I've had no problem just using
> TRISB without XOR'ing it
> (after switching to bank 1)  Just curious ...
>
> {Original Message removed}

2003\04\01@234502 by Russell C. Hay

flavicon
face
ahh .. I just tend to ignore that warning, but I'll update my current code
to include that.. sometimes it's hard to follow all of the discussions on
this list.. I probably read about 1% of all the messages that come across
because it becomes overwhelming..

{Original Message removed}

2003\04\02@054921 by Rick Regan

picon face
Banjo Spam wrote:

>Yes, it *is* completely obvious!! :-) Just kidding,
>but we all (together) did review this within the last
>few weeks.

>XOR'ing a register value with 0x080 gets rid of Error
>302 (I think that is the number). It also has the
>side effect of giving an error if the register is
>not in Bank 1.

I wrote:

> bsf TRISB ^ 0x080, 0 ; Set PortB 0.1.2 to output
> bsf TRISB ^ 0x080, 1
> bsf TRISB ^ 0x080, 2
>
> The comment says output, but you are setting them
> to input.

I was not commenting on the "XOR'ing a register value
with 0x080" issue.  I was trying to point out the
bug in the code.  'bcf' should be used instead of
'bsf' to set these PORTB bits to output.


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

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

2003\04\02@084139 by Olin Lathrop

face picon face
> To get myself accustomed to mcu programming I am trying to set up a
> stoplight style program.
> I am using the onboard USART and can get chars transmitted and received
> in hyperterminal. But I can't
> get the LEDs I attached to PortB bits 0, 1, and 2 to light up.

If you want to start with a working example and go from there, check out
my HOS project at http://www.embedinc.com/pic/hos.htm.  It is already set
up to control a single LED from Hyperterm.

> Does the use of PortB as the serial comm port somehow make the other
> bits on that port unusable?

Definitely not.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, 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

2003\04\03@032925 by jim barchuk

flavicon
face
Hello Charles!

> I am using the onboard USART and can get chars transmitted and received
> in hyperterminal.

Obviously you've gotten it to work, but *far* ((far) did I mention far?)
better is Tera Term http://www.ayera.com/teraterm/ It's *much* more
configurable and controllable. Hterm is fine for talking with 'known
working' hosts. But at the hardware level, testing, debugging,
experimenting, LEARNING and such, TTerm blows Hterm away like dust.

Have a :) day!

jb

--
jim barchuk
.....jbKILLspamspam.....jbarchuk.com

--
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

2003\04\03@120230 by Paul Hutchinson

flavicon
face
The version of TeraTerm revised by Ayera looks interesting although in a
quick look I didn't see any new features that would be useful to me. I also
wonder why they didn't release the source code like the original author.

The original version of TeraTerm and its source code are @
http://hp.vector.co.jp/authors/VA002416/teraterm.html

Paul


> {Original Message removed}

2003\04\03@135535 by jim barchuk

flavicon
face
Hi Paul!

On Thu, 3 Apr 2003, Paul Hutchinson wrote:

> The version of TeraTerm revised by Ayera looks interesting although in a
> quick look I didn't see any new features that would be useful to me.

Compared to Hterm or the previous version? I never used the previous so
don't know what those differences are. And don't recall what the new
version page mentions or whether you downloaded and tried it. The OP
mentioned Hterm and all I meant was that TTerm is radically diferent. I'm
talking detail/hardware stuff like resetting the terminal, screen, buffer,
and serial port on the fly, transmit line delay, set newline to CR or CRLF
on receive and transmit, editable keyboards, various VT emulations.

> I also wonder why they didn't release the source code like the original
> author.

Didn't know that was the case of the previous either. I am not excessively
annoyed or concerned as long as it works.

Have a :) day!

jb

--
jim barchuk
EraseMEjbspam_OUTspamTakeThisOuTjbarchuk.com

--
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 2003 , 2004 only
- Today
- New search...