Helpful ReplyReliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt

Page: 1234 > Showing page 1 of 4
Author
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
2017/10/14 00:24:00 (permalink)
0

Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt

Hello,
 
What is best way establish Reliable UART Communication (Baud Rate : 9600) Between dsPIC33EP
and PIC32MX without Interrupts  when both are Full Duplex .?
 
I have not any experiences on below signals.
 
(RTS)  Indicates the device is ready to send data
(CTS ) Indicates the device is ready to accept data
Delay in Milliseconds will not be an issue .
 
Please Advice...
 
 
--
TS9
#1
Nikolay_Po
Super Member
  • Total Posts : 1741
  • Reward points : 0
  • Joined: 2012/04/01 13:49:27
  • Location: Russia, Novorossiysk
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/14 00:45:10 (permalink)
3 (1)
Connect RTS of one chip to CTS of another and vice versa. Enable hardware flow control in UART configuration. In your SW send new data portion only when the transmission buffer is free. And pull the characters from RX buffer when possible and when there is a character(s) received. Due to hardware flow control the transmitter of one chip will transmit only when reception side is ready. I can't say particularly for PIC32MX but the above is common for any UART with RTS/CTS pins.
#2
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/14 01:33:59 (permalink)
0
Thanks for Update...Nikolay_Po
 
I have checked dsPIC33EP FRM and PIC32MX FRM Both supports Hardware Flow Control
as you guide me for default UART Options.
Do I need any other  Setting/Clearing/Checking in code rather than UEN<1:0> in Code.?
 
Attached UEN Setting..
 
TS9
 
post edited by TS9 - 2017/10/14 01:37:35

Attached Image(s)

#3
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/14 09:40:34 (permalink)
0
And How both will perform when one is keep sending and other will busy in 500us interrupts...?? Any setting in program avoid this situation
post edited by TS9 - 2017/10/14 09:48:17
#4
dan1138
Super Member
  • Total Posts : 2897
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/14 10:22:06 (permalink)
3 (1)
To assure long term reliability for asynchronous serial streams you will need to verify that the maximum relative error in baud rate between the two endpoints is less than 2.5% and if possible less than 1%.
 
You need to account for ALL error sources. These included at minimum: the oscillator frequency accuracy and actual baud rates used at both endpoints. Depending on your design there may be other error sources.
#5
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/14 14:05:54 (permalink)
0
Thanks dan1138..

But how to use RTS and CTS pins....? As written in Msg #3...
#6
NKurzman
A Guy on the Net
  • Total Posts : 16665
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/14 14:27:42 (permalink)
3 (1)
Assuming you have configured and connected it correctly. You will find the senders tx buffer stays full until the receiver signals the sender signals it to send its data.
post edited by NKurzman - 2017/10/14 14:43:19
#7
qhb
Superb Member
  • Total Posts : 7914
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/14 17:02:08 (permalink)
3 (1)
TS9
...
Delay in Milliseconds will not be an issue .

What does this actually mean?
If the receiver will always poll the USART before the receive FIFO fills, then you don't need hardware handshaking at all.
 
#8
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/14 17:48:04 (permalink)
0
@NKurzman
1)
Any Special Setting in Program except UEN?
2)
When to read Receive buffer?
3)
How to send priority between Interrupts and Handshaking signals?
Interrupts should be higher priority
4)What will be receiver do if transmitter transmit more fast then receive (may busy in Interrupts ) ?
5)Transmitter transmits, queue or only last updated byte in case as 4)
6)Any Demo code without harmony.

@qhb
Yes, UART MODE (Not USART) Polling data is slower (Execution of infinite loop in main) than Transmit rate.
Then I am skipping some bytes.

Hardware Handshaking is want to use apart from Interrupts. UART Should able to all receive data..
post edited by TS9 - 2017/10/15 10:46:27
#9
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/15 10:38:25 (permalink)
0
Any Update??
#10
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/18 07:51:18 (permalink)
0
Please Update....
Anyone has experience with UART Hardware Handshaking..
post edited by TS9 - 2017/10/18 08:15:31
#11
dan1138
Super Member
  • Total Posts : 2897
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/18 12:08:41 (permalink)
4.67 (3)
TS9
Please Update....
Anyone has experience with UART Hardware Handshaking..

You are perhaps misunderstanding how this forum usually works.
 
This is a user supported forum, Microchip employees do read and occasionally respond but, the vast majority of the useful replies come from independent developers. These developers provide the help they do without expectation of compensation. This is not a place to expect to get a complete and comprehensive response to any request for help.
 
Now to be more specific to your thread. You have posted a request for help using a UART to communicate between  dsPIC33 and PIC32MX type controllers using the hardware handshake support provided in the UART function block of each controller.
 
It would seem that no developer that has done this has responded to your request for help with a specific implementation. It is unlikely that a developer would setup the hardware to develop and test firmware for this specific configuration for free.
 
To get the kind of assistance you seem to need will require that you try to create code for both controllers and demonstrate that you understand how to use the development tools for both target controllers.
 
It seems possible to use MPLAB Harmony to generate a project for the PIC32MX and the MPLAB Code Configurator to generate a project for the dsPIC33 to initialize the UART and create a simple test application that can send data back and forth across the interface.
 
You will need to provide a circuit diagram of the hardware you will be using to test your firmware implementation. Please understand that this circuit diagram should be only the UART interface. A circuit diagram describing your entire project would not be helpful.
 
Using development boards from Microchip to setup a test platform will have a better chance of other developers being willing to assemble the same hardware that you have to evaluate your firmware.
 
To sum up: It is for you to take the next step and show what you can get done.
 
If you do not understand how to do any of the things I have suggested say so and we can start from the basics.
#12
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/19 12:33:02 (permalink)
0
Thanks for long reply.. and correcting me..

If you do not understand how to do any of the things I have suggested say so and we can start from the basics.

There is not need to start from very basics.
I am written Initialization code on both the side with CTS , RTS Pin Setting ..

Now to be more specific to your thread. You have posted a request for help using a UART to communicate between dsPIC33 and PIC32MX type controllers using the hardware handshake support provided in the UART function block of each controller.

It would seem that no developer that has done this has responded to your request for help with a specific implementation. It is unlikely that a developer would setup the hardware to develop and test firmware for this specific configuration for free.

To get the kind of assistance you seem to need will require that you try to create code for both controllers and demonstrate that you understand how to use the development tools for both target controllers.

It seems possible to use MPLAB Harmony to generate a project for the PIC32MX and the MPLAB Code Configurator to generate a project for the dsPIC33 to initialize the UART and create a simple test application that can send data back and forth across the interface.


// PIC32MX795F512L
void INIT_UART2_PIC32MX(void)
{
U2BRG = BAUDRATEREG_2;
U2MODE = 0;
// UEN = 0x10 (UxTX, UxRX, UxCTSand UxRTSpins are enabled and used)
U2MODEbits.UEN= 0b10 ; // Enable RTS/CTS Mode
U2MODEbits.BRGH = BRGH_2;
U2STA = 0;
U2MODEbits.UARTEN = 1;
U2STAbits.UTXEN = 1;
IFS1bits.U2RXIF = 0;
 
#if defined (__PIC32MX__)
U2STAbits.URXEN = 1;
#endif
}
// dsPIC33EP512MU810
void INIT_UART2_dsPIC33EP(void)
{
U1BRG = BRGVAL ; // Set Baud Rate to the value calculated by the
// BRGVAL macro defined above
U1MODEbits.UARTEN = 1; // enable UART
// UEN = 0x10 (UxTX, UxRX, UxCTSand UxRTSpins are enabled and used)
U1MODEbits.UEN= 0b10 ; // Enable RTS/CTS Mode
 
U1STAbits.UTXEN = 1; // enable UART TX
U1STAbits.URXISEL = 0; // interrupt after a characters is received
__C30_UART=1; // assiciates printf with UART1
 
__builtin_write_OSCCONL(OSCCON & ~(1<<6)); //Unlock Registers
// Assigned to UART1 TX
RPOR11bits.RP108R = 1 ; //RF12 (U1TX ) Pin 40
// Assigned to UART1 RX
_U1RXR = 77 ; // RPI77 (U1RX Pin 80 )
// Assigned to UART1 CTSR
RPINR28bits.U4CTSR = 1 ;
// U1RTS (RP79/RD15) Pin 48
RPOR4bits.RP79R = 0b00000010 ;
// _U1CTSR (RPI17) Pin 38
_U1CTSR = 17 ;
__builtin_write_OSCCONL(OSCCON | (1<<6)); // Lock Registers
}

My Question as in Msg #9 from general UART not specific to any MCU...
1) Any Special Setting in Program except UEN? (Except this one)
2) When to read Receive buffer?
3) How to send priority between Interrupts and Handshaking signals?
Interrupts should be higher priority
4)What will be receiver do if transmitter transmit more fast then receive (may busy in Interrupts ) ?
5)Transmitter transmits, queue or only last updated byte in case as 4)
 
Any Way.........
Thanks.. Again
 
TS9
post edited by TS9 - 2017/10/19 12:40:17

Attached Image(s)

#13
Gort2015
Klaatu Barada Nikto
  • Total Posts : 2769
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/19 19:03:40 (permalink)
0
RTS and CTS, that's old school.
 
Why not use SPI or I2c, you'll get faster comms.

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
#14
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/19 19:49:23 (permalink)
0
Because of Distance of Few meters in 1.5 meter.
#15
Gort2015
Klaatu Barada Nikto
  • Total Posts : 2769
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/19 20:03:04 (permalink)
3 (1)
Ok
You may want a checksum to be sent or some better quality cable like ethernet cable.
 
What cable are you using?

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
#16
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/19 21:35:35 (permalink)
0
Serial Cable... My issue is Protocol, not Cable.
post edited by TS9 - 2017/10/19 21:41:03
#17
Gort2015
Klaatu Barada Nikto
  • Total Posts : 2769
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/20 19:29:21 (permalink)
0
4.  You get strange results, that's why I suggested a checksum.  Send data twice, the 2nd in reverse bit order.  Possibility to recover data or do a re-send.
 
Google serial, there will be a wiki.

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
#18
dan1138
Super Member
  • Total Posts : 2897
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/21 21:44:06 (permalink)
0
TS9
My Question as in Msg #9 from general UART not specific to any MCU...
 
1) Any Special Setting in Program except UEN? (Except this one)
 
2) When to read Receive buffer?
 
3) How to send priority between Interrupts and Handshaking signals?
Interrupts should be higher priority
 
4) What will be receiver do if transmitter transmit more fast then receive (may busy in Interrupts ) ?
 
5) Transmitter transmits, queue or only last updated byte in case as 4)

To recap a bit:
From post #1 you requested:
"What is best way establish Reliable UART Communication (Baud Rate : 9600) Between dsPIC33EP
and PIC32MX without Interrupts  when both are Full Duplex .?"
 
From post #9 you requested:
"6) Any Demo code without harmony."
 
From post #13 you posted some code fragments to attempt to setup UARTs for the dsPIC33EP512MU810 and the PIC32MX795F512L, but these fragments are too incomplete to build.
 
As you do not seem interested in examples that use the Microchip code generation tools like Harmony, MCC or the legacy peripheral libraries I am not sure how to try to help you.
 
How about you post complete "main.c" files that build for each of the dsPIC33EP512MU810 and PIC32MX795F512L target devices. The main() function should set all of the GPIO pins for digital I/O and initialize the system clock to the frequency you want each target to operate at. This way you can avoid using any Microchip supplied code.
#19
TS9
Super Member
  • Total Posts : 595
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: Reliable UART or (USART) Communication Between dsPIC33EP and PIC32MX without Interrupt 2017/10/21 21:56:06 (permalink)
0
Ok... Thanks for update..

Is there any Demo code? For UART with RTS and CTS on MC Web or in FRM?
#20
Page: 1234 > Showing page 1 of 4
Jump to:
© 2018 APG vNext Commercial Version 4.5