Forum > Embedded
Extra beginners help with memory addresses I2C on RPI3 and FPC-AVR
(1/1)
pascalbythree:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- //***************** WVW I2C ******************************** SystemCore:= TFastSystemCore.Create; GPIO:= TFastGPIO.Create(SystemCore); PortI2C:= TFastI2C.Create(GPIO); AddrI2c:= $1E; // Address of my test component PortI2C.SetAddress(AddrI2C); //*************************************************
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- //******************* WVW I2C **************************** RegE:= Hex2Dec('78'); // I use a TEdit to load the register Val := random(255); if (val>ord('a')) and (val<ord('z')) then begin Writeln('VAL = '+IntToStr(Val)+' - '+chr(val)); PortI2C.WriteByteData(RegE, val); end; //*******************************************************
Jow FPC engineers!
Can anybody help with trying the right memory adresses for:
AddrI2c:= $1E;
RegE:= Hex2Dec('78');
I am trying to I2C and i need ultra simple replies to get it to work
Greetz Wouter!
PS aftherwards i need to work on my FPC-AVR code, to also set up the right addresses there also.
pascalbythree:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program WVW_BURN; uses uart, i2c, delay; {atmega328p} var i2c_master: TI2CMaster; x: byte; c: char; counter : byte; begin // Initialize UART that is interrupt controlled UART_Init1(9600,true); uart_transmit('WVW UART TEST STRING '); i2c_master.init(I2C_100kHz); Counter := 0; repeat Counter := Counter + 1; if counter = 100 then counter := 1; uart_transmit('Inside MAIN loop'#10#13); uart_transmit('Counter = '); uart_transmit(counter); uart_transmit(#10#13); i2c_master.start($1E, true); i2c_master.readByte(x, false); i2c_master.stop; uart_transmit('I2C Vallue = '); uart_transmit(x); uart_transmit(#10#13); uart_transmit(#10#13); delay_ms(55); until false; end.
This is the code for the AVR side. Can anybody screen what to change? to make them connect.
This is the I2C unit at the AVR side:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit i2c; interface uses atmega328p; type { TI2CMaster } TI2CMaster = object retVal: byte; procedure init(bitRate: byte); // Address should be left adjusted 7-bit value function start(address: byte; readTransaction: boolean): boolean; function readByte( data: byte; ack: boolean): boolean; function writeByte(data: byte): boolean; function stop: boolean; end;
kupferstecher:
Seems you have on both sides a I²C master implemented?
Navigation
[0] Message Index