12.07.2015 Views

Programming Manual Elektor Proton Robot - ELEKTOR.se

Programming Manual Elektor Proton Robot - ELEKTOR.se

Programming Manual Elektor Proton Robot - ELEKTOR.se

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Proton</strong> main program for AVR in C:/*************************************************************/ Main program for <strong>Elektor</strong> proton robot/ U<strong>se</strong>d uC – ATMEGA32 - Xtal 19660800/ VDD = 5V - VSS = GND/ Written by Bart Huyskens - Jan 2011/*************************************************************/#include #define F_CPU 19660800UL#include #include "AVR_PROTON_LIB.h"#include "AVR_PROTON_LIB.c"int main ( void ){_delay_ms(250);_delay_ms(250); //wait for stable power supply}// write your code hereAVR_PROTON_LIB.h/*************************************************************************I2C/TWI FUNCTIONS - I2C/TWI FUNCTIONS - I2C/TWI FUNCTIONS - I2C/TWI FUNCTIONS**************************************************************************///Initiali<strong>se</strong> PIC16F887 for Hardware I2C operationvoid I2C_INIT();// <strong>se</strong>nd a start bit <strong>se</strong>quencevoid I2C_START();// <strong>se</strong>nd a repeated start bit <strong>se</strong>quencevoid I2C_RESTART();// <strong>se</strong>nd a stop bit <strong>se</strong>quencevoid I2C_STOP();// transmit a byte (this can be a devide adress - an index or just data - of 8 bit// if return = 1 : No ack bit was received from the slave - if return = 0 = a correct acknowledge bit was receivedchar I2C_TRANSMIT_BYTE(char Data);//receive a byte of data - requested by the master and <strong>se</strong>nt by the slave// returns a byte of incoming data// if last = 1 - last byte was received - If last = 0 - the master expects further I2C_RECEIVE_BYTE instructionschar I2C_RECEIVE_BYTE(char Last);//combination of all the I2C instructions to <strong>se</strong>nd a byte of date to a specific// index in a certain devicevoid I2C_SEND_MESSAGE(char Device_ID, char AddrH, char Data);Bart Huyskens <strong>Manual</strong> <strong>Elektor</strong> <strong>Proton</strong> V1.0 3 April 2011 161

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!