Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Software UARTs in PIC18F452

Status
Not open for further replies.

adwnis123

Full Member level 4
Joined
Jun 19, 2014
Messages
214
Helped
0
Reputation
0
Reaction score
1
Trophy points
18
Activity points
1,737
How many software UARTs can I use in a PIC microcontroller??
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,458
Helped
4,745
Reputation
9,505
Reaction score
4,520
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
123,303
As many as there are pins available but the more you use the slower they will all become. Most software UARTS in compiler libraries are blocking, meaning that once a serial byte has started to arrive, the routine waits until the last bit has been received before continuing the program again. This obviously makes it difficult to use more than one at a time but by carefully coding your own UART routines it is possible to use many in parallel.

Brian.
 

zuisti

Advanced Member level 1
Joined
Jul 2, 2004
Messages
480
Helped
188
Reputation
376
Reaction score
182
Trophy points
1,323
Location
Hungary
Activity points
3,281

adwnis123

Full Member level 4
Joined
Jun 19, 2014
Messages
214
Helped
0
Reputation
0
Reaction score
1
Trophy points
18
Activity points
1,737
As many as there are pins available but the more you use the slower they will all become. Most software UARTS in compiler libraries are blocking, meaning that once a serial byte has started to arrive, the routine waits until the last bit has been received before continuing the program again. This obviously makes it difficult to use more than one at a time but by carefully coding your own UART routines it is possible to use many in parallel.

Brian.
By meaning carefully on C code ? Or assembly?
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,666
Helped
14,078
Reputation
28,411
Reaction score
12,742
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,928
I think it's not a problem of assembler versus C code. The problem is about mastering low-level PIC programming, particularly interrupts and timers. It can be achieved in C, a few lines of inline assembler can be helpful.
 

adwnis123

Full Member level 4
Joined
Jun 19, 2014
Messages
214
Helped
0
Reputation
0
Reaction score
1
Trophy points
18
Activity points
1,737
I think it's not a problem of assembler versus C code. The problem is about mastering low-level PIC programming, particularly interrupts and timers. It can be achieved in C, a few lines of inline assembler can be helpful.
So, if I want to use 2 software Uarts of mikroelektronika's library, they will work??
 

zuisti

Advanced Member level 1
Joined
Jul 2, 2004
Messages
480
Helped
188
Reputation
376
Reaction score
182
Trophy points
1,323
Location
Hungary
Activity points
3,281
So, if I want to use 2 software Uarts of mikroelektronika's library, they will work??
Yes, I think they will work but you must always re-init the mikroC Software UART library routines via the proper Soft_UART_Init, before using the other sw uart.
But ... I'm not sure that the Soft_UART_Break is also working in both case. Try it.


Or ... use the Multi-SwUart library (written by me, link: see my post above). Its disadvantage: only one baudrate, same for all. Advantage: much smaller code.
 
Last edited:

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top