View previous topic :: View next topic |
Author |
Message |
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
How much UART can define CCS? |
Posted: Thu Jun 11, 2020 3:32 pm |
|
|
Normally I use 2 uart by hardware and 2 uart by software ( using int0,int1,int2, or int_RB). but I want know if CCS let me make 6 UART?
Like this:
TX0, RX0 (hardware)
TX1, RX1 (hardware)
TX2( any pin), RX2 (ext_int0)
TX3( any pin), RX3 (ext_int1)
TX4( any pin), RX4 (ext_int2)
TX5( any pin), RX5 (any PIN of int_RB4-8)
Thanks you. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9270 Location: Greensville,Ontario
|
|
Posted: Thu Jun 11, 2020 3:42 pm |
|
|
Quick comment...
You can have as many hardware UARTS as a PIC has, and several software UARTS. The problem is all software UARTS are 'bitbanged', so timing is critical.
I have an old compiler so I don't know if CCS has changed the compiler to allow what you post. Others will know for sure.
So if you need lots of UARTS with ultra fast response( IE: interrupt driven) you'll need external peripheral UARTS. At one time (yes, when the dinosaurs roamed...) you could by a 'quad UART'. Perhaps someone makes such a device today ?? |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
Posted: Thu Jun 11, 2020 4:48 pm |
|
|
temtronic wrote: | quick comment...
You can have as many hardware UARTS as a PIC has, and several software UARTS. The problem is all software UARTS are 'bitbanged', so timing is critical.
I have an old compiler so I don't know if CCS has changed the compiler to allow what you post. Others will know for sure..
So if you need lots of UARTS with ultra fast response( IE: interrupt driven) you'll need external peripheral UARTS. At one time(yes, when the dinosaurs roamed...) you could by a 'quad UART'. Perhaps someone makes such a device today ?? |
Thank you for the answer.
I need make a device with 3 uart (GPRS, WIFI, Debug) but i need 2 uart more for 2 sensors that use serial port.
Maybe is not complex the timing response... so that is the reason i need know if ccs let. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9270 Location: Greensville,Ontario
|
|
Posted: Thu Jun 11, 2020 5:08 pm |
|
|
Ok, I went to Microchip's website > parametris search > chose 8 bit PICs > seelcted 5 UARTS....
magically about 10 or so are shown !
They're probably faifly new devices, so check to see if your versaion of the compiler will work for them. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19590
|
|
Posted: Thu Jun 11, 2020 11:56 pm |
|
|
and, yes CCS happily lets you run with these. I'd suspect there will be a limit
somewhere, but have yet to hit it. Have a project running at the moment with
the PIC24FJ512GB610, have 6 hardware serials all running merrily.
Be aware with what you show, that once the code is receiving a character
on one of the software ports, it won't be able to receive on any of the
others, till this character is complete. Also, receiving characters will
interfere with transmission.
Generally, unless characters are very infrequent, this is not going to
be a reliable way to work.
So CCS will allow you to set this up, but _using_ it, is not likely to be
really practical... |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Fri Jun 12, 2020 6:14 am |
|
|
Related to above: There's a line in the ccs manual for kbhit().
For reliable operation in software UART, you must poll kbhit() with at least ten times the frequency of your baud rate. Otherwise you will miss incoming characters. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9270 Location: Greensville,Ontario
|
|
Posted: Fri Jun 12, 2020 6:48 am |
|
|
I got curious... found this..
https://www.maximintegrated.com/en/products/interface/controllers-expanders/MAX14830.html
there's probably more available, about $10US makes me think a PIC with HW UARTS would be cheaper, easier and smaller.
One 'trick' using software UARTS is to reduce baudrate. Microchip had an 'application note' very early (25 years ago)... about making a mouse using a PIC. While in assembler it had very,very clever coding like checking switch statuses(sp) while bitbanging data to the PC.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19590
|
|
Posted: Fri Jun 12, 2020 7:06 am |
|
|
He doesn't have to poll, since he is using hardware interrupts to trigger
the actual start of the getc. However the issue remains that once a
character starts receiving, the code will be stuck in the interrupt handler
for the whole duration of the character. If another arrives on any of
the other ports while this is happening, it will be missed....
I'm assuming this since his notes in each case mention an interrupt
for each of the RX lines. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19590
|
|
Posted: Fri Jun 12, 2020 7:10 am |
|
|
As a comment, the Maxim IC, is 3* the price of the PIC with 6 UARTs..... |
|
|
|