hamster Posted June 6, 2013 Report Share Posted June 6, 2013 Hi, I've been quite quiet lately but here is my latest project: http://hamsterworks.co.nz/mediawiki/index.php/I3C2 It is a small programmable controller that makes it quick and easy to talk to I2C devices. The controller has a single I2C bus, 16 binary inputs, 16 binary outputs and write I2C data to 32 8-bit registers. It has a simple assembler-like language of 15 instructions, and the page includes a single file 'c' assembler written using only the standard C library (avoiding trying to find flex and yacc for Windows). Here's some sample code:;===============================================================; Reading from the HMC5883L Compass (I2C device ID is 0x3C / 0x3D);--------------------------------------------------------------- WRITE 0x3C ; Switch to continious measurement mode WRITE 0x02 WRITE 0x00 STOP reread: WRITE 0x3C ; Start Write transaction WRITE 0x03 ; Ponter to Reg 3 STOP WRITE 0x3D ; Start Read transaction MASTERACK READ 0 ; Reg 3 - X, most significant byte MASTERACK READ 1 ; Reg 4 - X, least significant byte MASTERACK READ 2 ; Reg 5 - Y, most significant byte MASTERACK READ 3 ; Reg 6 - Y, least significant byte MASTERACK READ 4 ; Reg 7 - Z, most significant byte READ 5 ; Reg 8 - Z, Least significant byte (no MACK on last read) STOP SET 0 ; Indicate that new, consistent data is available CLEAR 0 DELAY 32768 ; Wait for approx 1/10th of a second JUMP reread Link to comment Share on other sites More sharing options...
alvieboy Posted June 9, 2013 Report Share Posted June 9, 2013 Hey Hamster, How much space does your "cpu", or "sequencer", uses ? Link to comment Share on other sites More sharing options...
hamster Posted June 9, 2013 Author Report Share Posted June 9, 2013 *um*, a rather heavy 160 slices (blush). It goes down to about 140 if you remove the MASTERACK instruction, but it is so useful! That is with most of the 16 outputs and inputs wired to something. It also depends on if the code is large enough that it gets inferred as BRAM rather than LUTs (of course you want it in BRAM if you intend to update it with DATA2MEM... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.