.:EDIT:. This ultimately didn’t work so unless you enjoy a story continue onto part 2.
Well I’ve had to take a break from working on the avr vga output. For a project I needed to interface with a ENC28J60 ethernet controller by microchip. The controller is used in quite a few hobby ethernet devices so there is quite a bit available code to play about with. Sadly I wasn’t able to find anything written for the MSP430. I decided to modify this code for the arduino. First test is just to remove any c++ type code as my project is going to be exclusively C. Next test is to see just how much needs rewritten.
I quickly found that the majority of the code doesn’t need to be changed. Except for anything to do with SPI. The avr that the arduino is based off uses a different system to operate compared to the MSP430. Here is an example of some arduino code for a write followed by a read.
CSACTIVE; // issue read command SPDR = op | (address & ADDR_MASK); waitspi(); // read data SPDR = 0x00; waitspi(); // release CS CSPASSIVE; return(SPDR);
This was modified as follows.
CSACTIVE; // issue read command UCB0TXBUF = op | (address & ADDR_MASK); waitspi(); // read data //SPDR = 0x00; //waitspi(); // release CS CSPASSIVE; return(UCB0RXBUF);
The problem is I am not entirely sure how it knows to read in data to the receive buffer. Note though that in this version instead of one buffer that is used for input and output there are two buffers. More reading of the data sheet will therefore have to be done.