hi all, iam a new to embedded programming and keil software. i am struck with a problem how to access a bit in a data buffer. the algo i need to implement is data_buf of 32 bits is stored in the micro controller. i need to send those bits bit by bit. ie. starting from bit 0 to bit 31. can anybody pls suggest me how to write a program in keil. thanks in advance uday
Seems over-complicated to me: Why not just shift the 32-bit number, mask the LSB, and send it direct?
for( i=0; i<32; i++ ) { DATAPIN = wordToSend & 1; wordToSend >>= 1; }
HI, ofcourse that works for 32 bits and will occupy less instructions. I was considering a generic function which can send a byte. Depending on his size he may call this function accordingly. Cheers, Ravi
"I was considering a generic function which can send a byte." Even more reason to keep it simple:
for( i=0; i<8; i++ ) { DATAPIN = byteToSend & 1; byteToSend >>= 1; }