Forum Discussion
Altera_Forum
Honored Contributor
15 years agoalt_getchar returning wrong value
int main()
{
int noia = 0;
alt_putstr("Proc 2!\n");
/* get the mutex device handle */
alt_mutex_dev* mutex = altera_avalon_mutex_open( "/dev/mutex" );
/* acquire the mutex, setting the v...
Altera_Forum
Honored Contributor
15 years agoHi, Are you new to C programs ?
Your printf will print hexadecimal value. because of "%x" try
noia = alt_getchar();
alt_printf("%c\n", noia);
But later in your code I see if (noia == 1) ! If you type with keyboard, alt_getchar may return between 40 and 124 (decimal values). So if you want you condition to be true you have to Press Alt with 0 then 0 then 1. If you want your condition to be true when you type '1' with keyboard, try if (noia == '1') noia should be declared as char (not "int"). Or this is an other problem.