Searching \ for 'USART Configuration' 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/io/serials.htm?key=usart
Search entire site for: 'USART Configuration'.

Truncated match.
PICList Thread
'USART Configuration'
1999\08\11@122125 by Mario Thomaidis

picon face
Hello,

I have searched through the logged listserv files but have found
contradictory or insufficient information about initialising the USART
(I am using a PIC16C73A).

Specifically, when I simulate using MPLAB4.12, the TIF bit (PIR1<4>)
(initialised as 0) is not set once the TXEN bit (TXSTA<5>) is set, as
the PIC16C7X device literature indicates. Also, once I force a write to
TXREG, and wait Tcy, the TXIF bit remains unset. Behaving equally as
strangely is the TRMT bit (TXSTA<1>). It is initialised set (as the
literature indicates), but after the forced write, it does not clear (as
the literature indicates it should). The problem seems to be the same
one - TXREG is not moved to TSR (no TXIF bit set), so TRMT remains set.

I am new to this listserv, but I imagine inline code is a no-no. If
anyone knows what the problem is and can provide direction (or a code
fix!), please feel free to send it to me directly. Of course, I can
provide my code if anyone wants it ;)

Mario

1999\08\11@151928 by Mark Willis

flavicon
face
Mario Thomaidis wrote:
> <snipped>
> I am new to this listserv, but I imagine inline code is a no-no. If
> anyone knows what the problem is and can provide direction (or a code
> fix!), please feel free to send it to me directly. Of course, I can
> provide my code if anyone wants it ;)
>
> Mario

 Small code snippets aren't a problem, say 20 lines or less roughly?
Give or take a big margin <G>  It's easy enough to get a web page &
stuff the whole thing up to a web page (Heck, zap it to me & I'll stick
it on here if needed), good to keep bandwidth somewhat minimized, but we
don't need to be TOO silly about it (Doesn't make sense to spend 23
lines describing how to snag a 15-line piece of source code, plus it's
symptoms, when the same 23 lines could show the code plus symptoms.)
Some people read the PICList offline, and like it when you include more
code (as they're on the train or bus while reading the list, and can
hardly jump online to snag the code & figure out what's up!), etc.

 Mark

1999\08\12@142119 by Mario Thomaidis

picon face
Hello,

I am new to PICs and am having trouble initialising the USART on a
16c73a. I only need the use of the transmitter, but am trying to
initialise both TX and RX since I don't know if only one can be used.
Can anyone help? If it matters, I am simulating with MPLAB 4.12. As per
Mark's indications, I am including the following code:

; Intializing PORTC
  BCF      STATUS, RP0    ; Select Bank 0 (for PORTC)
  CLRF     PORTC          ; Clear output data latches
  MOVLW    b'11000000'    ; Initialize data direction
  BSF      STATUS, RP0    ; Select Bank 1 (for TRISC)
  MOVWF    TRISC          ; Set RC<5:0> as outputs, RC<7:6> as inputs
                          ;  RC<7:6> really USART TX and RX

; Initialize the USART
  BSF      STATUS, RP0    ; Bank 1 (SPBRG)
  MOVLW    0x09           ; BRG Control Value
  MOVWF    SPBRG          ;
  BCF      STATUS, RP0    ; Bank 0 (RCSTA)
  MOVLW    b'10010000'    ; SPEN=1, CREN=1
  MOVWF    RCSTA          ;
  BSF      STATUS, RP0    ; Bank 1 (TXSTA)
  BSF      TXSTA, TXEN    ; Enable transmission

The problem is that after I set TXEN, the TXIF bit is not set (it should
be set since the TXREG is empty, shouldn't it?). Later on in my code, I
loop on TXIF, to see if TXREG is empty, but the program gets stuck
there. I tried adding the following code to transmit something first and
then loop on TXIF (maybe TXIF isn't set after TXEN is set (after a reset
that is)):

; Transmit something
  BCF      STATUS, RP0    ; Bank 0 (TXREG)
  MOVLW    0xFF           ;
  MOVWF    TXREG          ;

; Transmit again
  BCF      STATUS, RP0    ; Bank 0 (PIR1 & TXREG)
LOOP
  BTFSS    PIR1, TXIF     ;
  GOTO     LOOP           ;
  MOVLW    0xAA           ;
  MOVWF    TXREG          ;

Once again, the program gets caught in the loop. What am I doing wrong?
I've also tried looping on TRMT (TXSTA<1>), but to avail; actually the
opposite happens - I can always write to TXREG because TRMT is always
set.

Some other oddities I've notice:

1) Although TRMT (TXSTA<1>) is read-only, I can write to it. At least
that's what the simulator indicates - does this have to do with the data
latches (I would hope the simulator would be absolute)?

2) On the general mid-range PIC data sheet (DS31018A), Section 18
(USART), Example 18-2: Asynchronous Transmitter/Receiver, TXSTA is
initiated with 0x40. The comments beside this initialisation is: "8-bit
transmit,  transmitter enabled, asynchronous mode, low speed mode", but
0x40 is: 9-bit transmit, transmitter DISabled, asynchronous mode, low
speed mode. I imagine this example is in error looking at the 16c7x data
sheets (and the page before the code on DS31018A).

Oddity 2) above is especially perplexing since writing 0x40 to TXSTA
would clear TRMT for me (as per oddity number 1) above).

Can anyone help?

Mario

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