glenjoy
Banned
- Joined
- Jan 1, 2004
- Messages
- 962
- Helped
- 72
- Reputation
- 146
- Reaction score
- 20
- Trophy points
- 1,298
- Location
- Philippines
- Activity points
- 0
Hi,
I have seen this code and wondering if this is really working to get an 8 bit MSB first data. Please post comments:
unsigned char read_0831(){
unsigned char bit;
clk = 0;
bit = d_out;
clk = 1;
return bit;
}
unsigned int start_read(){
unsigned char i;
unsigned int adc_data;
adc_data = 0;
csel = 0;
for(i=0;i<8;i++) {
adc_data = adc_data | read_0831() <<1;
csel = 1;
}
}
1. Is the content of the char bit 1000 000 or 0000 0001 if d_out is equal to one.
2. Is this code right? because I am confused with the rotate left if it will put in adc_data the correct arrangement of bits from the adc.
I am sorry to ask this, but I am a beginner in C, I am used in assembly programming.
Thanks.
I have seen this code and wondering if this is really working to get an 8 bit MSB first data. Please post comments:
unsigned char read_0831(){
unsigned char bit;
clk = 0;
bit = d_out;
clk = 1;
return bit;
}
unsigned int start_read(){
unsigned char i;
unsigned int adc_data;
adc_data = 0;
csel = 0;
for(i=0;i<8;i++) {
adc_data = adc_data | read_0831() <<1;
csel = 1;
}
}
1. Is the content of the char bit 1000 000 or 0000 0001 if d_out is equal to one.
2. Is this code right? because I am confused with the rotate left if it will put in adc_data the correct arrangement of bits from the adc.
I am sorry to ask this, but I am a beginner in C, I am used in assembly programming.
Thanks.