MCF52211 UARTS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCF52211 UARTS

Jump to solution
1,400 Views
Edu2011
Contributor II

Hello everyone.

 

I'm new to FREESCALE.  I am currently using the M52211EVB. I am making a program that reads data from the UART0 and must send them via the UART1, as I have to initialize and use separately each of these ports? If there is any quick and efficient way of doing this please tell me.  Best regards

Labels (1)
0 Kudos
1 Solution
1,024 Views
mjbcswitzerland
Specialist V

Hi Eduardo

 

I am not sure whether you have mis-typed the EVB.

If you have the M52211 EVB you need to select the defines _M521XX and M52211EVB (make sure M52210DEMO is commented out).

 

I don't think that there is an M5211EVB; there is an M5213EVB and if you have one of those select _M521X and M5213EVB.

 

You just need to build and the project will be configured for that board type (any parts that can't run on that type of processor will be automatically disabled).

 

To initialise and use the UARTs see the UART user's guide (link in previous post in thius thread). You can also follow this: http://www.utasker.com/forum/index.php?topic=54.msg220#msg220

 

You can open UARTs also for single direction. Eg.

 

SerialPortID1 = fnOpen(TYPE_TTY, ucDriverMode, &tInterfaceParameters);

fnDriver(SerialPortID1, (TX_ON), 0);

 

to open only for transmission.

Or

SerialPortID2 = fnOpen(TYPE_TTY, ucDriverMode, &tInterfaceParameters);

fnDriver(SerialPortID2, (RX_ON), 0);

 

to open only for reception.

 

They can be configured for interrupt or DMA operation and handle XOF/XOFF or hardware flow control if required.

 

Regards

 

Mark

 

 

View solution in original post

0 Kudos
10 Replies
1,024 Views
scifi
Senior Contributor I
0 Kudos
1,024 Views
TomE
Specialist II

Yes, start with CFInit, but don't use the one Freescale provide as it is very old. Go here:

 

http://www.microapl.co.uk/CFInit/cfinit_main.html

That gets you initialisation code. You then need something to copy the data between the ports. Do you need buffering? Do you need flow control? Can you run a simple "polling loop" or does your application require you do this properly with interrupts?

 

If you can, get a proper operating system to do the initialisation and provide the drivers. You shouldn't have to reinvent all these wheels.

 

In response to your original question, the "easiest software solution" is to load Linux and then run the shell command "cat /dev/ttys1 > /dev/ttys2", but that's really cracking a walnut with a nuclear missile :smileyhappy:

 

Tom

 

0 Kudos
1,024 Views
Edu2011
Contributor II

Hi Tom,

 

Thanks for your good response. I´m using windoows XP and C++.to programm the MCU. I´m develping and application to receive data, modfied it and then sent it to  radio modem.

 

I need t read  GPS data using the Serial port 0, then I edit the info I got from the GPS, format it and send it using the Serial Port #1 to  a radio modem.

 

this is the reason I need to know how to initialize and control serial ports of this MCU. It is obvious I´m familiar with serial prts concept.

 

if you can give me your best  advice, I´ll be very gratefulled.

 

Regarding Interrupts, The ansewer is YES. I´ll use interrupts.( in emergency case= Panic button)

 

Flow Conrol: NO, I´ll not use flow control.

 

Buffering : NO needed.

 

GPS will send automatically the infformation to the MCU ( asynchronic). As soon as the data form GPS  is available, I´ll process it in the MCU and send it ( modified) trough another serial port.

 

Regards,

 

Eduardo

0 Kudos
1,024 Views
TomE
Specialist II

> CFInit is supported by M52211EVB (MCF52211)?

 

CFInit is a Windows program that generates example C code for initialising MCF CPUs.

 

CFInit doesn't list the MCF52211. It does support 50 other CPUs and 11 development boards.

 

Since all you want is an example of UART initialisation, pick the "closest" CPU that CFInit supports and compare the UART chapters of the Reference Manuals. The Coldfire manuals are all "cut and paste" jobs of chapters that match the modules that the chip is made from, so apart from the chapter and page numbers you'll find the chapters match. If they don't, pick another chip reference manual until they do.


Then get CFInit to generate the initialisation code for a couple of UARTs and start with that.

 

> I´ll use interrupts.( in emergency case= Panic button)

 

I don't see that as a requirement for interrupts. A simple "polling loop" can poll for a panic button press.

 

You have everything you need to design a simple flow-chart for the program to do what you need it to do.

 

The program is:

 

0 - Initialise everything.

1 - If there's an incoming byte in the UART, read it and store in a buffer.

2 - If there's output data in the buffer and the output UART is ready, send another byte.

3 - When there's a full receive buffer (when the terminator is there), process it into the output buffer.

4 - Keep an eye on the Panic Switch.

5 - Blink LEDs and so on.

6 - Go back to step 1.

 

That's easy. What isn't easy is coding up all the initialisation, all the interrupt service code, buffering and whatever "operating system" you need to support your program.

 

That's what products like uTasker are for.

 

Is this a commercial product or a hobby? If it is a hobby, then uTasker is free. If it is a commercial product, then uTasker is $485. How much is your time worth? How much do you cost to your employer? How many hours is $485 worth? How many hours/days/weeks is it going to take you to get this project working, then debugged?

 

Tom

 

0 Kudos
1,024 Views
mjbcswitzerland
Specialist V

Hi Eduardo

 

When you try with the uTasker project don't forget that it will allow you to simulate the M52211 in real-time on the computer. This will allow you to develop and test the project without the need to work on the target for much of the work.

 

In the case of the UARTs, each time the code configures the Coldfire UARTs the simulator will use the values set to the Coldfire registers to configure COM ports on the PC to the same settings. You can then connect the external devices (like GPS or radio modem) to the com ports of the PC and the interrupt routines of the UART driver code will be executed each time a character is received from these so that your application code can the handle the data. All data that your application sends to the UARTS will be sent out to the COM ports of the PC. This allows developing, testing and debugging the application in this environment as if you were working with the real device (the simulator uses Microsoft Visual Studio - the free express edition is adequate - it also allows coding with the VS editor, which is probably one of the best in the world). Once all operates as required you can cross compile to the M52211 (using Codewarrior, GCC or IAR), load to the board and it will run in the same, tested manner (the simulator executes the identical code and so - baring any simulator errors and some things that can't be simulated with the same absolute timing resolution - will work the same; during development, the simulator should already detect any coding errors in the application or when working with Coldfire peripherals).

 

The UART simulation is discusses more here:

http://www.utasker.com/forum/index.php?topic=343.0 (and in some other posts there).

 

The same concept extends to most peripherals - also the USB interface can be simulated (although more limited since the PC can't be a real USB device). When working with Coldfire processors with Ethernet, the PC will also allow the simulated device to communicate in real-time over Ethernet, which makes such development much simpler...;-)

 

Regards

 

Mark

 

P.S. If you later want to move to different Coldfire V2 chips changing a project setting will allow the same project code to run on different devices. This also extends to moving from V2 devices to the Kinetis family - simply configure the Kinetis define and the project will run on that chip (excepting a few port defines that will need to be modified since they don't all have compatible port layouts).

 

 

0 Kudos
1,024 Views
Edu2011
Contributor II

Ok Mark, thank you for you advice.

But, I purchased the evaluation board (M5211EVB and USB ColdFire Multilink).  Can I use this with uTasker products?  Essentially I need to know how to initialize the UART (0) and UART (1) and how I could use this in my program. I need use each UART separately. An UART  for RX another UART for TX.

 

Regards

Eduardo

0 Kudos
1,025 Views
mjbcswitzerland
Specialist V

Hi Eduardo

 

I am not sure whether you have mis-typed the EVB.

If you have the M52211 EVB you need to select the defines _M521XX and M52211EVB (make sure M52210DEMO is commented out).

 

I don't think that there is an M5211EVB; there is an M5213EVB and if you have one of those select _M521X and M5213EVB.

 

You just need to build and the project will be configured for that board type (any parts that can't run on that type of processor will be automatically disabled).

 

To initialise and use the UARTs see the UART user's guide (link in previous post in thius thread). You can also follow this: http://www.utasker.com/forum/index.php?topic=54.msg220#msg220

 

You can open UARTs also for single direction. Eg.

 

SerialPortID1 = fnOpen(TYPE_TTY, ucDriverMode, &tInterfaceParameters);

fnDriver(SerialPortID1, (TX_ON), 0);

 

to open only for transmission.

Or

SerialPortID2 = fnOpen(TYPE_TTY, ucDriverMode, &tInterfaceParameters);

fnDriver(SerialPortID2, (RX_ON), 0);

 

to open only for reception.

 

They can be configured for interrupt or DMA operation and handle XOF/XOFF or hardware flow control if required.

 

Regards

 

Mark

 

 

0 Kudos
1,024 Views
Edu2011
Contributor II

Hi Tom,

I was reviewed the link, and i think is very interesting, but ,the CFInit is supported by M52211EVB (MCF52211)?

I need program the MCU. this program must communicate with a device (gps) connected with a cable rs323 serial in the UART1 and th UART0 must send data to an external device (CPU or Radio/cell modem). It is an asynchronuous communication.

 

Regards

 

Eduardo

 

0 Kudos
1,024 Views
mjbcswitzerland
Specialist V

Hi

 

See also: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF - Includes MCF52211

 

regards

 

Mark

 

0 Kudos
1,024 Views
Edu2011
Contributor II

Thank you Mark i'm going to review this link.

 

Regards

 

Eduardo

0 Kudos