View previous topic :: View next topic |
Author |
Message |
RoProe
Joined: 03 Mar 2005 Posts: 6
|
Soft- or Hardware UART, where can I see this |
Posted: Thu Mar 10, 2005 4:23 am |
|
|
Hello,
I want to use the hardware Uart on my PIC (16F877).
But I think the compiler use a Soft uart?? Is there any way to see what the compiler implement? The Hard or Soft uart.
Thanks for help. |
|
|
Paolino
Joined: 19 Jan 2004 Posts: 42
|
|
Posted: Thu Mar 10, 2005 5:54 am |
|
|
Well, if you setup:
Code: | #use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) |
you tell the compiler to use the built-in UART, because pins C6 and C7 are internally connected to the hardware UART. If you specify different pins, you use software UART.
Refer to the datasheet: it is the first source of information!
Paolo. |
|
|
RoProe
Joined: 03 Mar 2005 Posts: 6
|
|
Posted: Thu Mar 10, 2005 6:10 am |
|
|
Hi,
thats right. but if I use the Hardware Pins and Speed that is not supported by the hardware, it also use the Softuart. |
|
|
Paolino
Joined: 19 Jan 2004 Posts: 42
|
|
Posted: Thu Mar 10, 2005 6:39 am |
|
|
If baud rate is not compatible with the osc frequency, the compiler generate an error and does not compile (the error is BAUD RATE IS OUT OF RANGE) and you can not use neither the hardware UART nor the software one.
Paolo. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 10, 2005 10:11 am |
|
|
Quote: | Is there any way to see what the compiler implement ?
The Hard or Soft uart. |
Yes. Look at the .LST file generated by the compiler. If the compiler
is using the hardware USART, when it transmits a character it will test
bit 0x0C.4 in a loop and then move the character into register 0x19.
(This is the TXREG in the 16F877). If you see a short block of code
like this, you're using the hardware USART:
Code: |
0000 00306 .................... putc(0x55);
0014 3055 00307 MOVLW 55
0015 1E0C 00308 BTFSS 0C.4
0016 2815 00309 GOTO 015
0017 0099 00310 MOVWF 19
0000 00311 .................... |
If the compiler is using a software USART, you will not see any writes
to register 0x19. The program will typically jump to a low address in
ROM with a large block of code (35 or more lines) that starts like this:
Code: |
0004 1683 00285 BSF 03.5
0005 1306 00286 BCF 06.6
0006 1283 00287 BCF 03.5
0007 1306 00288 BCF 06.6
0008 3008 00289 MOVLW 08
0009 00F8 00290 MOVWF 78
000A 0000 00291 NOP
// continues for approximately 30 more lines |
|
|
|
RoProe
Joined: 03 Mar 2005 Posts: 6
|
|
Posted: Thu Mar 10, 2005 10:14 am |
|
|
Thank you for your help. Now i can see what is Software and Hardware uart. |
|
|
|