Forum > Embedded - AVR

From AVR Master to RPIZERO slave, still not working... Using PXL.

(1/1)

pascalbythree:
I am back!

Afther working for it on a day everything works fine, to parse strings from a RPI Master using PXL, to a AVR Slave. Using I2C.

Except:

Now i need to do it the other way around,  to send data from my AVR over I2C to my RPI.

This is the code for the RPI:


--- 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_PXL_I2C_TEST; uses  SysUtils, PXL.TypeDef, PXL.Boards.Types, PXL.Sysfs.UART, PXL.Boards.RPi, crt;  var      SystemCore: TFastSystemCore;  GPIO: TFastGPIO;  PortI2C: TFastI2C;  AddrI2c, RegE: Byte; // Address of the component  value, i:byte;  s,S2:String;  counter: byte; begin  SystemCore:= TFastSystemCore.Create;  GPIO:= TFastGPIO.Create(SystemCore);  PortI2C:= TFastI2C.Create(GPIO);  AddrI2c:= $18; // Address of my test component  PortI2C.SetAddress(AddrI2C);      counter := 0;  repeat     counter := counter + 1;         if counter = 255 then counter := 1;         writeln(counter,  'Begin LOOP');      //WVW ORIGNAL function ReadByteData(const Command: Byte; out Value: Byte): Boolean; override;//WVW ORIGNAL function WriteByteData(const Command, Value: Byte): Boolean; override;                          //PortI2C.WriteByteData($18, ord(S[i]));                if PortI2C.ReadByteData($18, value) then writeln('Value=',Value,' ', chr(value));                                delay(55);  until keypressed;          PortI2C.Free;  GPIO.Free;  SystemCore.Free;  end. 
This is the code for the AVR Master:


--- 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_AVR_MASTER;         uses      uart, i2c, delay; {atmega328p}         var      i2c_master: TI2CMaster;      i, x: byte;      c: char;      counter : byte;          s:String;         begin            // Initialize UART that is interrupt controlled       UART_Init1(115200,true);           uart_transmit('Start!');                  s:='[UART TEST STRING]';                        i2c_master.init(I2C_50kHz);             Counter := 0;      repeat           Counter := Counter + 1;           if counter = 100 then counter := 1;           uart_transmit(counter);                              i2c_master.start($18, true);                              for i:=1 to length(S) do                   begin              i2c_master.writeByte(Ord(S[i]));                               delay_ms(1);                   end;                              i2c_master.stop;                   uart_transmit('END LOOP');           delay_ms(5);                         until 1=2;         end.
Can somebody help me out getting this to work ?

Greets, Wouter van Wegen, PascalByThree.

Navigation

[0] Message Index

Go to full version