|
|
View previous topic :: View next topic |
Author |
Message |
07arunsharma
Joined: 05 Mar 2012 Posts: 18 Location: India
|
Using Multiple Serial Port on RTOS??? |
Posted: Mon Jul 09, 2012 6:34 am |
|
|
I am using PIC18F4550 uC and wants to use multiple Serial Port with it, instantaneously like i am using interrupt..
Thats why i plan to use RTOS with it..
So as to process the Incoming Data Efficiently without any loss..
But the problem i am facing is due to this line...
Code: | receive_ch = fgetc(COM_A); |
First of all have a look at my code...
Code: |
#include<18f4550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
#use RS232(BAUD=9600, XMIT=PIN_C1, RCV=PIN_C2,FORCE_SW, STREAM=COM_A)
#use RS232(BAUD=9600, XMIT=PIN_C4, RCV=PIN_C5,FORCE_SW, STREAM=COM_B)
#use RS232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7,FORCE_SW, STREAM=COM_C)
int1 flag_a, flag_b, flag_c;
char receive_ch;
#use rtos(timer = 0, minor_cycle = 100ms)
//Rate Specify that Task will run every 100ms
//Max will specify the Maximum Time the task will run
#task(rate=100ms,max=100ms)
void the_first_rtos_task()
{
if(flag_a == 0)
{
fprintf(COM_A,"\r\nCOM_A Running\r\n");
flag_a = 1;
}
else
{
receive_ch = fgetc(COM_A);
fputc(receive_ch,COM_A);
fprintf(COM_A,"\r\n");
}
}
#task(rate=100ms,max=100ms)
void the_second_rtos_task()
{
if(flag_b == 0)
{
fprintf(COM_B,"\r\nCOM_B Running\r\n");
flag_b = 1;
}
else
{
receive_ch = fgetc(COM_B);
fputc(receive_ch,COM_B);
fprintf(COM_B,"\r\n");
}
}
#task(rate=100ms,max=100ms)
void the_third_rtos_task()
{
if(flag_c == 0)
{
fprintf(COM_C,"\r\nCOM_C Running\r\n");
flag_c = 1;
}
else
{
receive_ch = fgetc(COM_C);
fputc(receive_ch,COM_C);
fprintf(COM_C,"\r\n");
}
}
void main()
{
unsigned char receive_ch;
flag_a = 0;
flag_b = 0;
flag_c = 0;
set_tris_b(0x00);
fprintf(COM_A,"Serial PORT-A Transmission Okay\n\r");
fprintf(COM_B,"Serial PORT-B Transmission Okay\n\r");
fprintf(COM_C,"Serial PORT-C Transmission Okay\n\r");
rtos_run();
}
|
Due to that line my Program is executing step by step....
first task then second task and then third task...
in a particular order...
But i want to execute when data from outside is coming..
Pls help...
Thanks in advance _________________ Arun Sharma |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Mon Jul 09, 2012 7:53 am |
|
|
The only way you'll get 3 serial ports(or more) to run in 'realtime' is to have each of them tied to a hardware UART. The 4550 has one, so you need a peripheral device with 2 hardware uarts with the ability to send the PIC an interrupt.
This way each serial port can receive data, buffer it, then the main program (via ISRs) can deal with the data as required.
Some PICs have 2 h/w UARTs built in which MIGHT be acceptable providing you can compromise on the 3rd serial port either by using another pin (say ext int) or using it as a 'low' priority port.
hth
jay |
|
|
07arunsharma
Joined: 05 Mar 2012 Posts: 18 Location: India
|
|
Posted: Mon Jul 09, 2012 10:30 am |
|
|
Means there is no alternative way to do so....
Actually i need 8 UART ports in a single controller and PIC is having maximum two... I thought a rtos will serve my purpose...
as i have to replace ATxmega128A1 (having 8 uart) in a project
if there is any solution please let me know....
Still searching a solution... _________________ Arun Sharma |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Mon Jul 09, 2012 1:10 pm |
|
|
What baud rates are you wanting?
You do seem to have two similar threads going!
I'm only going to respond to one.
Mike |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Mon Jul 09, 2012 3:23 pm |
|
|
simple, easy solutions include..
1) using the octal UART from NXP..SCC2698B..
or
2) two pieces of QUAD UARTS, from several different mfrs.
or
3) fours pieces of Dual UARTS,again several mfrs make them.
It's up to you to decide what's best for your project depending on your hardware ability,software is easy. Cost of the 'system'...you'll have to work out.
My choice would be two...QUAD UARTS..as it reminds me of my LSI-11 design/build interfaces days... |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Jul 09, 2012 4:18 pm |
|
|
Serial transmitting is not so difficult, but receiving is difficult, especially at higher baudrates and multiple channels.
Why can't you use the Atmel chip anymore? At €6 it is not too expensive.
The mentioned SCC2698B is getting old and therefor expensive, €20+
For better answers you will have to provide more info:
How many channels?
Are all channels equal?
What baudrate?
Receive & transmit?
All at the same time?
Synchronized or not?
etc. |
|
|
07arunsharma
Joined: 05 Mar 2012 Posts: 18 Location: India
|
|
Posted: Mon Jul 09, 2012 8:16 pm |
|
|
Mike Walne wrote: | What baud rates are you wanting?
You do seem to have two similar threads going!
I'm only going to respond to one.
Mike |
I want to use baud rate of 9600bps... _________________ Arun Sharma |
|
|
07arunsharma
Joined: 05 Mar 2012 Posts: 18 Location: India
|
|
Posted: Mon Jul 09, 2012 8:21 pm |
|
|
temtronic wrote: | simple, easy solutions include..
1) using the octal UART from NXP..SCC2698B..
or
2) two pieces of QUAD UARTS, from several different mfrs.
or
3) fours pieces of Dual UARTS,again several mfrs make them.
It's up to you to decide what's best for your project depending on your hardware ability,software is easy. Cost of the 'system'...you'll have to work out.
My choice would be two...QUAD UARTS..as it reminds me of my LSI-11 design/build interfaces days... |
Thanks for your reply...
Actually i need 8 uart in a single controller, and the problem is that i am only familiar with PIC and 8051 Family (AT89S Family) and i am having programmers for that only....
That's why avoiding other controller's having multiple uart...
and from the all post it looks like that we can't implement 8 uart in a single pic as per my need...
who have written mfrs what is this....
multiple function registers...
anyways thanks _________________ Arun Sharma |
|
|
07arunsharma
Joined: 05 Mar 2012 Posts: 18 Location: India
|
|
Posted: Mon Jul 09, 2012 8:24 pm |
|
|
ckielstra wrote: | Serial transmitting is not so difficult, but receiving is difficult, especially at higher baudrates and multiple channels.
Why can't you use the Atmel chip anymore? At €6 it is not too expensive.
The mentioned SCC2698B is getting old and therefor expensive, €20+
For better answers you will have to provide more info:
How many channels?
Are all channels equal?
What baudrate?
Receive & transmit?
All at the same time?
Synchronized or not?
etc. |
Actually i am not having programmer and kit for atmel micro-controllers
Not having any idea regarding avr series which is having 8 uart...
totally new with avr...
and atxmega128at comes in TQFN package so i can't handle it....
I need 8 channels
9600 bps for all
asynchronous communication is suffice for me _________________ Arun Sharma |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Tue Jul 10, 2012 1:31 am |
|
|
Do you actually need reception & transmission, or would just transmission be acceptable on some channels?.
8 channel serial transmission, is basically totally easy using a 9600Hz interrupt, even on quite a basic PIC. Reception gets successively harder. If only a couple of channels need to receive, then there are several pics offering two complete UART's. Receiving a limited number of channels using (say) an interrupt at 28800Hz, is quite 'doable', but the chip is going to be working hard, and will become able to do less and less other work as the number of channels rises.
Separately though, you are going to have to add external IC's to provide the level translation, and there are UART's with the translators 'built in', so the chip count remains the same with these....
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Jul 10, 2012 2:12 am |
|
|
I think you have a problem...
8 UARTs, single package, not TQFN package, only PIC or 8051 architecture. This is not going to fit.
The maximum for a PIC16/18 is 2 UARTs. The PIC24/32 have a maximum of 4 UARTs and these are a completely different architecture. Other processor architectures with 8 UARTs are rare, your atxmega128at is the only one I could find. The LPC3180FEL320 is an ARM9 based processor and goes up to 7 UARTs, but 320-LFBGA package is even more difficult than TQFN.
You will have to loosen some requirements.
Sorry, but as I said before, without more details about your application it is useless to try and give you more advice. Too many options exist to start just giving some general advice.
1) For context, what kind of device are you designing?
2) What order of production quantities? For low quantities it is best to spend more on pre-build hardware and save on the software labour costs where for large quantities it is the other way around.
3) Why do you want a single package? Is there a size limitation?
4) Give as much detail about the kind of data you are going to receive/transmit as possible. Data quantities for receive and transmit? All at the same time or random? All channels receive & transmit or some transmit/receive only? What kind of processing are you going to do? etc. etc. etc. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|