Ok so heres the function from which I'm returning the value. It is a switch-case function for the value of an i/p portD on a microcontroller. it prints the appropriate result on an LCD and returns this value to main(). Following this piece of code is the code from the main() which calls the function:
Code:
#define A_1 110
#define As_1 116
#define B_1 123
#define C_1 130
#define Cs_1 138
#define D_1 147
#define Ds_1 145
#define E_1 165
#define F_1 175
#define Fs_1 185
#define G_1 196
#define Gs_1 207
int print_value_1(void)
{
while(!RD7){}/////WAIT UNTIL BUTTON IS PRESSED////////////
RD7 = 0;
switch( PORTD )
{
case 0b01000001: lcd_puts("A"); return A_1;
break;
case 0b00100001: lcd_puts("A#"); return As_1;
break;
case 0b00010001: lcd_puts("B"); return B_1;
break;
case 0b01000010: lcd_puts("C"); return C_1;
break;
case 0b00100010: lcd_puts("C#"); return Cs_1;
break;
case 0b00010010: lcd_puts("D"); return D_1;
break;
case 0b01000100: lcd_puts("D#"); return Ds_1;
break;
case 0b00100100: lcd_puts("E"); return E_1;
break;
case 0b00010100: lcd_puts("F"); return F_1;
break;
case 0b01001000: lcd_puts("F#"); return Fs_1;
break;
case 0b00101000: lcd_puts("G"); return G_1;
break;
case 0b00011000: lcd_puts("G#"); return Gs_1;
break;
}
} //end of print_value
////////////////////////////// //////////////////////////
int main()
{
print_value_1();
int ret1 = print_value_1();
}