Bascom ---> Pascal

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Page 5 of 6
tbegle
Benutzer
Avatar
Gender: n/a
Age: 64
Posts: 150
Registered: 01 / 2018
Subject:

Re: Bascom ---> Pascal

 · 
Posted: 17.08.2022 - 08:50  ·  #33
Hi Dave , Hi Miparo,
and all the others involved in the compiler development of the MC of Microchip 4808/09 (UPDI), a big thank you.

The new MC are a hit! 1 PIN Prog. 1/2 current(Atmel) 48kB flash ........ !
I have tested the 3 USART on the 4808/09 (PIN TX=H!)
Wizzart - baudrates crooked values? - default buffer 0? maybe drill up to 230kBd? 4. USART ?
I2C(TWI) works fine I2C(TWI)presc?=TWI_BR 100/400?
AD-W still no function
Regards
Toni

Hallo Dave, Hallo MIparo,
und alle die Anderen die sich an der Compiler Entwicklung der MC von Microchip 4808/09 (UPDI) engagieren, einen herzlichen Dank.

Die neuen MC sind der Hit! 1 PIN Prog. 1/2 Strom(Atmel) 48kB flash ........ !
Ich habe die 3 USART am 4808/09 getestet (PIN TX=H!)
Wizzart - Baudraten krumme Werte? - default Buffer 0? vielleicht auf 230kBd aufbohren? 4. USART ?
I2C(TWI) funktioniert einwandfrei I2C(TWI)presc?=TWI_BR 100/400?
AD-W noch keine Funktion
Grüsse
Toni
Mathias
Benutzer
Avatar
Gender: n/a
Location: Weingarten - Baden
Posts: 307
Registered: 07 / 2003
Subject:

Re: Bascom ---> Pascal

 · 
Posted: 17.08.2022 - 13:35  ·  #34
Hallo,
habe die neueste Version installiert: 15.11.15
und das Programm von Miparo an einem Mega644 am Laufen.
Wie Miparo schon geschrieben hat, an der Druckmessung hängt es noch.
Hast du einen Tippe in welcher Ecke bei "procedure BME280readPressure" zu suchen ist?

Erstaunlich wie schnell du das Programm zum Funktionieren gebracht hast.

Gruß
Mathias
You must be logged in or your permissions are to low to see this Attachment(s).
miparo
Administrator
Avatar
Gender:
Location: Germany
Age: 59
Posts: 956
Registered: 09 / 2007
Subject:

Re: Bascom ---> Pascal

 · 
Posted: 17.08.2022 - 14:04  ·  #35
Hi Matthias,
ich habe es nur aus C übersetzt, mehr nicht.
Das Datenblatt habe ich nie gesehen. Chip gekauft , übersetzt und probiert :)
Das wird merlin beruhigen, das es mit der 15.11.15 läuft.Warum es bei mir nicht compilieren wollte ?
Jetzt geht es bei mir auch wieder. dubios.

miparo
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: Bascom ---> Pascal

 · 
Posted: 17.08.2022 - 14:13  ·  #36
I don't know if it helps but I saw this in Miparo's program

Code
function BME280read24(reg: byte): longword;

var
  Bytes3   : TRec;
begin
  Bytes3.Int_:= 0;
  I2Cout(BME280_ADDR, reg);
  I2Cinp(BME280_ADDR, Bytes3.Arr3);  // only read 3 bytes
  return(Swaplong(Bytes3.Int_) shr 8);

end;


I think that this should be

Code
function BME280read24(reg: byte): longword;

var
  Bytes3   : TRec;
begin
  Bytes3.Int_:= 0;
  I2Cout(BME280_ADDR, reg);
  I2Cinp(BME280_ADDR, Bytes3.Arr3);  // only read 3 bytes
  return(Swaplong(Bytes3.Int_  shr 8)); // << Bracket was in wrong place

end;


I cannot test but I believe I am right.

Regards

Merlin
miparo
Administrator
Avatar
Gender:
Location: Germany
Age: 59
Posts: 956
Registered: 09 / 2007
Subject:

Re: Bascom ---> Pascal

 · 
Posted: 17.08.2022 - 15:14  ·  #37
Hi Merlin,
possible, I will test that tomorrow. :)

miparo
miparo
Administrator
Avatar
Gender:
Location: Germany
Age: 59
Posts: 956
Registered: 09 / 2007
Subject:

Re: Bascom ---> Pascal

 · 
Posted: 18.08.2022 - 16:51  ·  #38
Hi Merlin,
I think mine is correct ?

Code

// Reads a signed 24 bit value over the I2C bus_REG
function BME280read24(reg: byte): longword;
var
  res : longword;
begin
  res:= 0;
  I2Cout(BME280_ADDR, reg);
  I2Cinp(BME280_ADDR, res, 3);  // only read 3 bytes 24-bit
  Writeln(Serout,'Int24 : '+  LongToHex(Swaplong(res) shr 8));  >>> result : 00831E00
  Writeln(Serout,'Int24L: '+  LongToHex(Swaplong(res shr 8))); >>> result: 1E000000
  return(Swaplong(res) shr 8);
end;



miparo
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: Bascom ---> Pascal

 · 
Posted: 18.08.2022 - 19:05  ·  #39
Hi Miparo.

I don't know the product or the format of the data. It is just that mathematically it made no sense to me. To be honest it still doesn't

You start with
00 00 00 00

Then read 3 bytes

aa bb cc 00

Then reverse the digits

00 cc bb aa

then shr 8

00 00 cc bb

That might be what you are trying to achieve but I am struggling to believe it. Or am I missing something?
miparo
Administrator
Avatar
Gender:
Location: Germany
Age: 59
Posts: 956
Registered: 09 / 2007
Subject:

Re: Bascom ---> Pascal

 · 
Posted: 18.08.2022 - 19:20  ·  #40
The safe way :)

Code

// Reads a signed 24 bit value over the I2C bus_REG
function BME280read24(reg: byte): longword;
var
  Buff: array[0..2] of byte;
begin
  I2Cout(BME280_ADDR, reg);
  I2Cinp(BME280_ADDR, Buff); // only read 3 bytes 24-bit
  return (longword(Buff[0]) shl 16) or (longword(Buff[1]) shl 8) or longword(Buff[2]));
end;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Page 5 of 6
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   135   149 · Page-Gen-Time: 0.026401s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI