Quantcast
Viewing all articles
Browse latest Browse all 63798

Forum Post: RE: msp430 i2c problems

You need helper functions like this: void switchFrom8To4Bits() { static unsigned char buf[2] = { 0x24, 0x20 }; dataTransmit = buf; size = 2; while(UCB0STAT & UCBBUSY); UCB0CTL1 |= UCTR + UCTXSTT; } void write2x4Bits(unsigned char bits, int is_data) { static unsigned char buf[4]; buf[0] = (bits & 0xf0) | is_data | 0x04; buf[1] = (bits & 0xf0) | is_data; bits <<= 4; buf[2] = (bits & 0xf0) | is_data | 0x04; buf[3] = (bits & 0xf0) | is_data; dataTransmit = buf; size = 4; while(UCB0STAT & UCBBUSY); UCB0CTL1 |= UCTR + UCTXSTT; } void writeCommand(unsigned char command) { write2x4Bits(command, 0); } void writeData(unsigned char data) { write2x4Bits(command, 1); }

Viewing all articles
Browse latest Browse all 63798

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>