[LAB3] PIO not working

[LAB3] PIO not working

by Cédric Oliver Portmann -
Number of replies: 2

Hello,

We are working on LAB 3 and trying to do part 3.2. Printf works for both processors and we can observe them on two different terminal instances at the same time. However when we try to access the common PIO port we don't get the expected behavior. The code is supposed to set the GPIO pins to HIGH and LOW after 20ms and 10ms respectively (as demanded in the Lab 3 description). However with the logic analyzer we get LOW during the measure period of 5s. (No HIGH periods). 

This is the code on CPU_0:




And this is the code for CPU_1:



And this is the platform designer file and the top_level: (not on the picture but the line is also there:  GPIO_0    : out std_logic_vector(35 downto 0) )






Your help is greatly appreciated!

CP and MW

In reply to Cédric Oliver Portmann

Re: [LAB3] PIO not working

by Sahand Kashani-Akhavan -

Hi,

In CPU0 and CPU1, you are calling

altera_avalon_mutex_lock(mutex, 1);

But the 2nd argument of the function is supposed to be a per-CPU identifier to know who owns the mutex. If both CPUs use the same ID of 1, then you're not really locking anything. In operating systems you don't need to give an identifier when using a mutex as the OS takes your process ID for this purpose and takes care of mapping the process ID to the mutex in the kernel. In an embedded application, however, there is no OS, so you have to use the raw interface of a mutex and supply the correct ID yourself.

I suggest you use an edge trigger on the logic analyzer rather than just sampling for 5s as it's possible you'll miss some event, whereas an edge trigger would only start sampling after the event you're looking for actually occurs.

In reply to Sahand Kashani-Akhavan

Re: [LAB3] PIO not working

by Matthias René Wüst -

Thanks a lot Sahand, that was ideed the problem. @Loïc Karl Droz in case you still need to know: you can set this in platform designer. Edit the cpu component and there you can find it (I think) in the last tab.