Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

UART(RS232) with 2xCPU

Altera_Forum
Honored Contributor II
903 Views

Hi 

 

How do I get my system with two CPU's to use the same RS232 UART as STDOUT? It works fine with only one, but when conneccted with two cpu's I get a "permission denied" message, and the my program(on chip) halts. 

 

I'm using a mutex to avoid collisions and I use JTAg for STDIN and debug. 

 

Any help? 

 

-Stian
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
196 Views

In general you can't use the same peripheral from multiple CPUs. 

 

For the specific case of the UART you are probably having interrupt problems. The first CPU puts some characters into the UART and then enables interrupts so it can find out when the buffer has emptied. When the interrupt occurs both CPUs will race to service it - it's random which one gets there first. The CPU which doesn't win the race will see a spurious interrupt and have undefined behaviour. 

 

If you select "use small drivers" then you will get the polled (non interrupt-driven) UART driver which won't suffer from these problems - but there will still be races between the CPUs which will occasionally lose characters. 

 

The only safe way to do this is to use two UARTs or one UART protected by a mutex, although the latter will still have problems with where received characters go to.
0 Kudos
Altera_Forum
Honored Contributor II
196 Views

To keep things simple, can you get by with an RS232 Uart and a JTAG Uart? In situations like these I usually give the resource to a single CPU, and if the data was intended for the other CPU then CPU1 passes the data to CPU2 (by whatever means available). Only problem with this is that you have to "tag" your data so that CPU1 knows whether it is for it or the CPU2. If this isn't an option let us know and maybe someone will have a more suitable idea.

0 Kudos
Altera_Forum
Honored Contributor II
196 Views

Thanks for replies 

 

The UART is used for output only. The idea was to have both cpu's to use the same uart, controlled by a mutex. The output should be shown with hyperteminal running on the host pc. Using two jtag modules shows output data on seprate windows in the IDE, but I want to collect them in one window.  

 

 

Stian
0 Kudos
Reply