Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

pic32 UART RX ISR for unknown length.

Status
Not open for further replies.

vinoth14

Junior Member level 1
Joined
Feb 27, 2015
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
184
Hi,

Can any one help me to solve PIC32 RX ISR for unknown data length.

Thanks in advance


regards
Vinoth M.
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
Hi,

Can any one help me to solve PIC32 RX ISR for unknown data length.

Thanks in advance


regards
Vinoth M.

you could use a ring buffer, e.g.
https://www.embedded.com/electronics-blogs/embedded-round-table/4419407/The-ring-buffer

even if data flow speed is variable so long as you can empty the buffer before it becomes full there is no problem

what happens when you get overflow (buffer full) ? could you
1. thorw away the oldest data?
2. ignore some of the imcomming data?
3. implement hardware or software flow control?

what processing do you have to do on the incomming data?
 

Tahmid

Advanced Member level 5
Joined
Jun 17, 2008
Messages
4,758
Helped
1,791
Reputation
3,574
Reaction score
1,650
Trophy points
1,393
Location
Silicon Valley, California, USA (from Dhaka, Bangl
Activity points
30,545
You could look into a (doubly) linked list - so think of it as a dynamic array if you don't know about it. Look it up. Keep in mind the efficiency requirements of allocating memory on the fly and for traversing the list if you have time-critical stuff.

Use malloc() and free() to allocate and deallocate space for your data structure (blocking). This way you can, while not necessarily ideal, keep adding elements until you run out of memory.

More details on your design target will help give better answers. :smile:
 

vinoth14

Junior Member level 1
Joined
Feb 27, 2015
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
184
you could use a ring buffer, e.g.
https://www.embedded.com/electronics-blogs/embedded-round-table/4419407/The-ring-buffer

even if data flow speed is variable so long as you can empty the buffer before it becomes full there is no problem

what happens when you get overflow (buffer full) ? could you
1. thorw away the oldest data?
2. ignore some of the imcomming data?
3. implement hardware or software flow control?

what processing do you have to do on the incomming data?


HI,

I want to receive data from modbus simulator and the same data is to be transmitting to same uart port.
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
HI,

I want to receive data from modbus simulator and the same data is to be transmitting to same uart port.

what speed are you receiving/transmitting data?

if it is just a question of receiving data and transmitting it onwards do you need to buffer it at all?

e.g. in an interrupt service routine receive a character and retransmit it (ssuming you are transmitting at the same or faster speed than receiving)

if you need to buffer data and do some processing could you double buffer it, e.g.

1. using DMA receive data into one buffer
while
2. processing data in second buffer and then transmitting it?
 

vinoth14

Junior Member level 1
Joined
Feb 27, 2015
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
184
what speed are you receiving/transmitting data?

if it is just a question of receiving data and transmitting it onwards do you need to buffer it at all?

e.g. in an interrupt service routine receive a character and retransmit it (ssuming you are transmitting at the same or faster speed than receiving)

if you need to buffer data and do some processing could you double buffer it, e.g.

1. using DMA receive data into one buffer
while
2. processing data in second buffer and then transmitting it?



Hi,

I made one mistake in my previous post, Whatever the data is receiving from ModBUS simulator I want to transmit it to other port.

I'm using 9600bps Baudrate.
I want to hold the data in second buffer. (I'm not indeed to use DMA)
 

horace1

Advanced Member level 5
Joined
Nov 18, 2008
Messages
2,123
Helped
596
Reputation
1,188
Reaction score
573
Trophy points
1,393
Location
Norwich, UK
Activity points
13,071
if you are receiving data and then immediatly retransmitting it why do you need a second buffer? are you doing further processing in the PIC32?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top