
A simple I2C master implementation on the MSP430 - simplyembedded
http://www.simplyembedded.org/tutorials/msp430-i2c-master/
======
iuguy
It's amazing how (comparatively) convoluted I2C is on platforms without the
Wire library support you see on Atmel platforms.

That's not to say that such platforms are bad (MSP430 has it's advantages and
disadvantages depending on what you want to do with it), but more of a
testament to the Wire library.

~~~
ctz
It's not too surprising that a high-level I2C abstraction looks less
convoluted than a register-level I2C driver.

Here's the equivalent code for the Atmel peripheral:
[https://github.com/arduino/Arduino/blob/master/hardware/ardu...](https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/libraries/Wire/src/utility/twi.c)

------
bArray
Getting a 503 error for the entire site...

Just went to find the page of internet archive:

    
    
        web.archive.org has been blocked by Sky Broadband Shield, which lets you choose the websites that can be seen in your home.
    

I hate ISPs. If someone could update the link, that would be grand!

~~~
majcherek128
Change your DNS servers?

~~~
gvb
503 is "Service unavailable" where the service is related to the web server,
not DNS.

[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_...](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_error)

~~~
q3k
Yes, but this is probably served by the ISP's servers, into which traffic was
redirected by the ISP's dishonest DNS.

This is much easier to implement than fully intercepting every HTTP
connection, and this is what most ISPs go with.

------
jwr
If someone is interested in a simple and straightforward implementation of I2C
on MSP430 with the USI module (the simpler serial module found on cheap low-
end chips), I wrote a library a couple of years back, because I couldn't find
anything I'd be happy with:
[https://github.com/jwr/msp430_usi_i2c](https://github.com/jwr/msp430_usi_i2c)

The code is also fully interrupt-driven, which is important for low-power
applications.

------
throwanem
This is much cleaner than TI's reference implementation.

~~~
jimmyswimmy
It may be so, but it doesn't implement an interrupt solution, which is a
really bad way to program a microcontroller.

Also I found these types particularly amusing. None of that code can be copy
pasted without editing:

    
    
      while ((err == 0) &amp;amp;&amp;amp; (nbytes &amp;gt; 0))
    

But since it doesn't support interrupts, I think not being able to copy paste
this code is generally a good thing.

~~~
throwanem
I'd tend to agree! But for those of us totally unfamiliar with how I2C works,
and barely familiar with embedded dev at all, a somewhat gentler introduction
to the relevant concepts, that requires close experience with fewer priors
than TI's reference example, is no bad thing to have.

