View previous topic :: View next topic |
Author |
Message |
boulder
Joined: 15 Mar 2008 Posts: 53
|
Hardware UART |
Posted: Tue Mar 25, 2008 6:13 pm |
|
|
Can I use #use 232() setup a hardware UART without setup_uart()? Or can I just use setup_uart() without #use 232()? Do I have to use Force_sw for software UART when I use #use 232()? Or does it mean it's hardware UART if I don't use Force_sw in #use232()? My chip is PIC16886.
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Mar 25, 2008 10:31 pm |
|
|
Quote: | Can I use #use 232() setup a hardware UART without setup_uart()? |
You normally only need setup_uart() if you want to change the baud rate
of the hardware UART at runtime.
Quote: | Or can I just use setup_uart() without #use 232()? |
No.
Quote: |
Do I have to use Force_sw for software UART when I use #use 232()? |
If you are using the hardware UART pins and you want a software UART
on those pins, then you must use FORCE_SW. That's because if you
specify the H/W pins, the compiler assumes you want to use the H/W
UART. If you want to override this, you must use FORCE_SW.
Quote: |
Or does it mean it's hardware UART if I don't use Force_sw in #use232()? |
If you specify the H/W pins, the compiler will use the hardware UART
by default.
To summarize:
On the H/W UART pins, you may specify a H/W or software UART. The
default is a H/W UART. You may force a S/W UART by using FORCE_SW.
On any other pins, only a software UART is possible. That's all it can do. |
|
|
boulder
Joined: 15 Mar 2008 Posts: 53
|
|
Posted: Tue Mar 25, 2008 10:40 pm |
|
|
Thanks. Now my mind is clear about UART setup. |
|
|
Guest
|
|
Posted: Wed Mar 26, 2008 3:16 am |
|
|
hello, just a concern about FORCE_SW.
It means that both pins will be SW driven, right, and RS-232 SW routines will be added? I dont get it since the RAM and ROM used is still the same as without FORCE_SW.
In other world, what is the difference between using HW UART and SW one?
cheers guys. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Mar 26, 2008 8:21 am |
|
|
Quote: |
It means that both pins will be SW driven, right, and RS-232 SW routines will be added?
|
Yes, SW routine must be added.
Quote: |
I dont get it since the RAM and ROM used is still the same as without FORCE_SW.
|
FORCE_SW do not generate code.
Quote: |
In other world, what is the difference between using HW UART and SW one?
|
The main difference is that HW UART generate an interrupt (if it is properly enabled)
in the START bit of the incoming data. While that if a SW UART is used, in order to sense
the START bit it is mandatory to do a polling at a minimum equivalent rate of the period
of one bit, or 10X the expected baud rate.
Humberto |
|
|
Ttelmah Guest
|
|
Posted: Wed Mar 26, 2008 9:04 am |
|
|
One thing that may confuse here, is that the routines are not actually generated, till they are _used_. So you can change the #use RS232 line, and compile, and see no difference in the code size. Only is there is a putc, or a getc, _using_ this definition, will the code size actually change.
Best Wishes |
|
|
Guest
|
|
Posted: Wed Mar 26, 2008 12:17 pm |
|
|
now i see,
cheers |
|
|
|