I need to display 0-15 hex numbers[0X00-0x0F] in decimal value...& I'm getting the output but it's not exactly what it should be,below is my code..
[This not the complete code,but main part where the changes are done]
Actual output i should get is for 1v it should generate 0001,for 2v it should generate 0010 and simultenously till [15v-1111]...
But what i'm getting is exactly different to this for eg for 7v,8v&9v the bits generated are 1101,1011,1011 respectively...
Please anyone help me in resolving this.. http://img.codecall.net/public/style...001_unsure.gif
Code:
:
Code:
sbit V1 = P2^0;
sbit V2 = P2^2;
sbit V3 = P2^4;
sbit V4 = P2^6;
#define DAC_table V1,V2,V3,V4
#include <stdio.h>
#include <string.h>
idata unsigned int ptr2tbl ;
void fnSelectAmplitude(void)
{
unsigned char DAC_table[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};//tell me if I have done wrong here
ptr2tbl == &DAC_table[16]; //is this correct I have used equal to'==' instead of assignment operator
line_display(1, "Amp Sel");
sprintf(line_buf," %03d V",(unsigned int)ptr2tbl);
line_display(2, line_buf);
while(START_KEY)
{
if(!UP_KEY)
{
for(i=0;i<15;i++)
{
P2 = ptr2tbl++;
}
}
else if(!DOWN_KEY)
{
P2 = ptr2tbl--;
}
else
{
++wait_for_any_key_counter_0;
if(wait_for_any_key_counter_0 >= 240) //120 to 240; Any Key not Pressed Delay is 120 * 75ms break;
}
delay_ms(75); // Debounce Delay
sprintf(line_buf," %03d V", (unsigned int)ptr2tbl);
}
delay_ms(500); // Screen Change Delay
}
main()
{
P2 = 0;
ptr2tbl = DAC_table; //i think here i'm doing wrong if i'll assign to address(&) operator i'm getting error
while(1)
{
disable_timer0();
}