USART

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

USART

Post by CharlieM » Wed Nov 03, 2010 11:06 am

Hello everyone,

Is is possible to use both software and hardware USART together on the same pic? I am using a 18F1220 and need to talk to a SGLCD and the PC. I want to use software USART for the SGLCD and the Hardware USART for the pc. Thanks.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Wed Nov 03, 2010 12:39 pm

In theory you should be able to, although personally I would try and use another type of software protocol (shift, for example) rather than software 232. If you have to use 232, use the lowest throughput with software

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Post by Jon Chandler » Wed Nov 03, 2010 12:56 pm

The software UART works well for transmitting data. Not so wll for receiving it in my experience.

I did have a moment of clarity a short while back regarding the software UART. If you're using the PICkit 2 to program, and then swapping connections to the UART pins just to monitor program parameters, use the software UART with PortB.7 to transmit. Program the PIC, then switch over to the UART tool without changing connections, Works brilliantly.



Jon

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Wed Nov 03, 2010 9:34 pm

Thanks. I am only send data via software USART to a Serial GLCD. For Programming and testing I am using a Easypic6.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Thu Nov 04, 2010 9:41 am

OK Another question. How does SF differentiate between using Soft USart and using the Hardware USart when using them together? both use Usart.write. It seems the software usart shoud be SUsart.write or something like that.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Thu Nov 04, 2010 10:02 am

You prefix with the module name. Type 'write' in the IDE and press F1 for a list of write options.

gramo
Registered User
Registered User
Posts: 200
Joined: Tue Mar 20, 2007 6:55 am
Location: Australia
Contact:

Post by gramo » Thu Nov 04, 2010 10:10 am

Open the module and search for the module identifier. For SUART.bas it is listed as:

Code: Select all

Module UART
Which means you can now use the UART identifier with dot notation to access any publicly visible objects, for example: UART.Write("Hello World")

In the case of USART.bas, it is listed as

Code: Select all

Module USART
Which as you have found out is used like so: USART.Write("Hello World")
digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples.

Australian distributor for the Swordfish Compiler

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Thu Nov 04, 2010 10:52 am

Thanks,

I must be dense this morning. When using the hardware USART and the Software USART together, both use Usart.write to send a byte to the usart buffer. If I have both the software usart and the hardware usart initialized what usart is going to be used? I have to include both "USART.bas and "SUSART.bas".There is nothing that says write to hardware buffer or write to software buffer? So I guess I can't use them together.[/b]

Thanks for the help.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Thu Nov 04, 2010 11:08 am

You can use them together. See online help or press F1 after typing 'write'. For example,

Code: Select all

USART.Write("boo",13,10) // write to hardware
UART.Write("boo",13,10)   // write to software
if you cannot work that way, alias the names. For example,

Code: Select all

Dim HW_Write As USART.Write,
    SW_Write As UART.Write

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Thu Nov 04, 2010 10:34 pm

OK David,
I see the difference now between using Uart and SUART. Thanks.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

Post Reply