Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

problem with mutex core

Dear all,

I've created a qsys system composed of two NIOS, each one attached to its on-chip memory that contains its program.

the two processors are connected to a shared RAM protected via a HW mutex core. I need that the first NIOS writes a data in the shared memory to be read by the second processor.

I write the following code for the first NIOS:

altera_avalon_mutex_lock( mutex, 1 );

if(altera_avalon_mutex_is_mine(mutex))

IOWR_32DIRECT(SHM,0x4,0x3);

altera_avalon_mutex_unlock( mutex );

And for the second NIOS:

altera_avalon_mutex_lock( mutex, 1 );

if(altera_avalon_mutex_is_mine(mutex))

{ data = IORD_32DIRECT(SHM,0x4);

printf ("data = %x \n",data);}

altera_avalon_mutex_unlock( mutex );

However, the NIOS2 always read a strange value (different from 0x3)

Please could anyone help me to solve the problem?

Thanks in advance,