shreyas_patel21
Full Member level 3

I am working on pic18f46k22
I have adjusted DAC output for controlling 1 to 12 V
I used case statement like if 1V is selected then DAC output should be 100mV and so on..
example code:
msb and lsb is for adjusting DAC.
I can also make equation instead of case statements
my question is "what requires less memory of pic case statement or equation?"
I have adjusted DAC output for controlling 1 to 12 V
I used case statement like if 1V is selected then DAC output should be 100mV and so on..
example code:
Code:
switch(voltage)
{
case 1:
msb = 0x00;
lsb = 0xb0;
break;
case 2:
msb = 0x14;
lsb = 0x20;
break;
case 3:
msb = 0x29;
lsb = 0x10;
break;
case 4:
msb = 0x3e;
lsb = 0x00;
break;
case 5:
msb = 0x51;
lsb = 0x70;
break;
case 6:
msb = 0x66;
lsb = 0x60;
break;
case 7:
msb = 0x7a;
lsb = 0x90;
break;
case 8:
msb = 0x8e;
lsb = 0xb0;
break;
case 9:
msb = 0xa2;
lsb = 0xe0;
break;
case 10:
msb = 0xb8;
lsb = 0xa0;
break;
case 11:
msb = 0xd2;
lsb = 0x30;
break;
case 12:
msb = 0xe0;
lsb = 0xf0;
break;
default:
msb = 0;
lsb=0;
break;
}
msb and lsb is for adjusting DAC.
I can also make equation instead of case statements
my question is "what requires less memory of pic case statement or equation?"