Samitha_ediriweera
Newbie level 2
- Joined
- Jul 2, 2010
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Colombo, Sri Lanka, Sri Lanka
- Activity points
- 1,295
How to define the lower and upper char(s) of an integer?
hi guys,
this is the code(s), i currently know,
Also,
isn't there a way i could define the adc lower & upper char(s) so that,
when ADRESL=0x34; and ADRESH=0x12; , then, adc reads 0x1234.
i.e. get the compiler to read ADRESL as the lower char & ADRESH as upper char of adc.
thanks in advance.
SAM
hi guys,
this is the code(s), i currently know,
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 union v{ unsigned int vint; unsigned char vchar[2]; }; main() { union v data; data.vchar[0]=ADRESL; data.vchar[1]=ADRESH; adc=data.vint; }
Also,
Code C - [expand] 1 2 3 4 main() { adc = (ADRESL | (ADRESH<<8)); }
isn't there a way i could define the adc lower & upper char(s) so that,
when ADRESL=0x34; and ADRESH=0x12; , then, adc reads 0x1234.
i.e. get the compiler to read ADRESL as the lower char & ADRESH as upper char of adc.
thanks in advance.
SAM
Last edited by a moderator: