Author Topic: LGT8F328P - clone of ATMega328 with lots of extras!  (Read 14161 times)

0 Members and 1 Guest are viewing this topic.

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
LGT8F328P - clone of ATMega328 with lots of extras!
« on: June 02, 2022, 06:30:38 am »
Given the rocketing price of AVR Aduinos, I've just been looking at these things...

https://www.aliexpress.com/wholesale?SearchText=LGT8F328P

The extra features are very interesting for a project I have in mind, both for the DAC and for the extra ALU.

I ordered a few (some purple, some green) and so far so good. They work just like Arduinos in the Arduino IDE.

Information on the extra features is very sparse though. There's the original datasheet that's been machine-translated by google on a couple of github repositories and very little else.

(FWIW: Google translate has improved, you can re-translate the manual today and google does a much better job)

I'm programming mine in assembly language. I'm particularly interested in the 16-bit ALUs. Has anybody else use them or does everybody simply switch them to 32MHz mode and use them as a faster Arduinos?

The way the new ALU works is not by having extra instructions (there's no bits left in the Atmel instruction set) but by monitoring the bus and seeing what you're doing.

eg. The 2kB of RAM is mapped twice in the address space on these chips. If you access the copy of RAM at 0x2000 then you can load/store 16-bit values in a single clock.

Example problem:

This instruction loads r0 with an 8-bit value from address 0x0100:

Code: [Select]
LDS R0,0x100
This instruction loads the DX register in the new ALU with a 16-bit value at 0x0100 and leaves r0 unchanged:

Code: [Select]
LDS R0,0x2100
(ie. same opcode, different result depending on the RAM address)

Problem:
It doesn't seem to work for any register other than DX. I believe I'm supposed to be able to load any register but it fails:

Code: [Select]
LDS R1,0x2100   ; Supposed to load the DY resister, but the value goes into DX instead!

Conversely, using the STS instruction to store 16-bit numbers works just fine:

Code: [Select]
STS 0x2100,R0   ; Store DX resister to location 0x100
STS 0x2102,R1   ; Store DY resister to location 0x102 - works perfectly!
STS 0x2104,R2   ; Store DAH to location 0x104 - works!
STS 0x2106,R3   ; Store DAL to location 0x106 - works!

 :scared:
« Last Edit: June 02, 2022, 06:44:49 am by Fungus »
 
The following users thanked this post: paf, ledtester

Offline GromBeestje

  • Frequent Contributor
  • **
  • Posts: 280
  • Country: nl
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #1 on: June 03, 2022, 01:11:16 pm »
How do you verify the values in the registers?
I've looked at the Logic Green datasheets way back when, and it mentioned some debugging interface. However, I haven't found a suitable debugger or any information about the debugging protocol. Have you found a suitable debugger to debug this chip?
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #2 on: June 03, 2022, 02:07:57 pm »
How do you verify the values in the registers?

I read them back (using the instructions that I found to work) and send them to the serial monitor in the Arduino IDE.

"dump_cpu" gives me a printout like this:

Code: [Select]
Program started OK

uDSC test 5
r1:r0 cafe  r9:r8   0000  r17:r16 0000  r25:r24 0135 
r3:r2 cafe  r11:r10 0000  r19:r18 4567       X: 2106
r5:r4 0000  r13:r12 0000  r21:r20 89ab       Y: 05d3
r7:r6 0000  r15:r14 0000  r23:r22 cdef       Z: 210c
DX: dead  DY: beef  DA: cafebabe

 :)

I can send you a copy of the code if you want to fiddle around.
« Last Edit: June 03, 2022, 02:14:29 pm by Fungus »
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #3 on: June 03, 2022, 08:04:41 pm »
Here's a copy of the code I've been using. Decompress it in your sketches folder.

nb. You don't need to do anything to the Arduino IDE, just connect up your LGT8F328P and select "Pro Mini" in the boards menu. It should work.

 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #4 on: June 03, 2022, 09:09:45 pm »
Is there any information on how deeply they sleep?  A bare bones 328P will sleep at some fraction of a microamp.  Will this one do that too?
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #5 on: June 04, 2022, 05:40:06 am »
Is there any information on how deeply they sleep?  A bare bones 328P will sleep at some fraction of a microamp.  Will this one do that too?

I imagine it will.

The datasheet I've got doesn't have any hard numbers but it talks a lot about the chip's power saving features. It has all the power saving modes of the 328P plus a few more.

I only have boards with built-in serial chip so it's a bit hard to test bare chip consumption.

« Last Edit: June 04, 2022, 07:17:48 am by Fungus »
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: gb
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #6 on: June 04, 2022, 11:14:14 am »
I hated datasheet that doesn't contains bookmarks for sections. Attached is the V1.0.5 document with three levels of bookmarks added for easy reference. It only takes me a few hours of work to do that.


 
The following users thanked this post: oPossum, paf, ralphrmartin, Fungus, ledtester, MK14

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #7 on: June 04, 2022, 04:08:53 pm »
I hated datasheet that doesn't contains bookmarks for sections. Attached is the V1.0.5 document with three levels of bookmarks added for easy reference. It only takes me a few hours of work to do that.

I've been doing the same as I go along. Not so systematic/detailed though.  :-+
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #8 on: June 04, 2022, 07:09:15 pm »
Summing up what I've found so far about the uDSC data transfer instructions:

Works:
Code: [Select]
in DX/DY/DA,address
out address,DX/DY/DA
sts address,DX/DY/DA   ; (via register names r0/r1/r2/r3)
ld DX/DY/DA,X/Y/Z
ld DX/DY/DA,X/Y/Z+
ld DX/DY/DA,-X/Y/Z
ldd DX/DY/DA,Z+q
st X/Y/Z,DX/DY/DA
st DX/DY/DA,X/Y/Z+
st DX/DY/DA,-X/Y/Z
std DX/DY/DA,Z+q

Doesn't work:
Code: [Select]
lds address,DX/DY/DA  ; nb. DX works, the others don't
ldd Rn,Z+q
std Rn,Z+q

(I'm not even sure what the last two are supposed to do, I can't get them to do anything at all... anybody?)

nb. I've tested on different boards (purple ones and green ones) so I don't think it's a faulty chip.

The datasheet goes on and on for two pages about how the "LDD Rn,Z+q" modes update Z after execution but it's the exact opposite of what's needed IMHO. I'd much rather Z stayed where it is so I can access a bunch of variables in a struct using Z as a base. It's made doubly painful by q only being positive so you can't go backwards. I'm predicting a lot of saving/restoring of the Z register!

There's even a half page diagram explaining how "Z+2" can give sequential access ... but if I want sequential data access I can just use "LD Rn,Z+". It works perfectly, changing Z by 2 after execution. :palm:

Meanwhile: The other instructions get almost no coverage at all, eg. The only clue that LDS/STS instructions can be used in this context is in the sentence "LDS/STS in the LGT8XM instruction set can access the 0x2100~0x28FF area, but the LDD/STD Y/Z+q addressing mode is more efficient."

(it's not more efficient if you have to set up Z first, eg. to load a single variable. I'd much rather have a working LDS instruction instead, but that's broken!)



As always, I guess I'll just have to muddle through using the instructions that seem to work... it's still going to be a win without 16-bit LDS.

« Last Edit: June 07, 2022, 02:16:32 pm by Fungus »
 

Offline Kerlin

  • Regular Contributor
  • *
  • Posts: 181
  • Country: au
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #9 on: June 07, 2022, 12:06:58 am »
Thanks for the update.
Interesting to see how other information seems to have been deliberately derailed then locked out.
No such problems here.
Do you know what the thread is about and are Comprehending what has been said ?
 

Offline tepalia02

  • Regular Contributor
  • *
  • Posts: 100
  • Country: bd
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #10 on: June 19, 2022, 02:14:21 pm »
Datasheet available?
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #11 on: June 19, 2022, 02:40:05 pm »
Datasheet available?

I grabbed the Chinese datasheet and ran it through Google translate.

Datasheet: http://www.lgtic.com/upload/lgt8fx8p/LGT8FX8P_databook_v1.0.4.pdf

Translate it here: https://translate.google.com/?sl=auto&tl=en&op=docs

That's how all the other "English datasheets" on the web have been made, it's worth doing it again because they're mostly three or four years old and google constantly evolves.

There's enough information in there to figure out what you need to know. Don't forget that it's ATMega328 compatible so you can refer to the Atmel datasheet for most things and only use the translated datasheet for LGT-specific features.

There's a few Githubs with other info and system files that are tweaked to fix millis(), serial baud rates, etc. for 32MHz:

https://github.com/dbuezas/lgt8fx

https://github.com/RalphBacon/LGT8F328P-Arduino-Clone-Chip-ATMega328P
« Last Edit: June 19, 2022, 02:43:36 pm by Fungus »
 
The following users thanked this post: paf

Offline tepalia02

  • Regular Contributor
  • *
  • Posts: 100
  • Country: bd
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #12 on: June 25, 2022, 10:22:28 am »
 Thank you so much for all this info and links.
 
The following users thanked this post: Fungus

Offline agarza

  • Newbie
  • Posts: 2
  • Country: mx
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #13 on: July 26, 2022, 11:21:38 pm »
Is there any information on how deeply they sleep?  A bare bones 328P will sleep at some fraction of a microamp.  Will this one do that too?

I imagine it will.

The datasheet I've got doesn't have any hard numbers but it talks a lot about the chip's power saving features. It has all the power saving modes of the 328P plus a few more.

I only have boards with built-in serial chip so it's a bit hard to test bare chip consumption.

The best power consumption on sleep I have achieved is ~170µA, nowhere near the 1µA@3.3V that is mention on the manual
 
The following users thanked this post: Fungus

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #14 on: July 27, 2022, 12:17:09 am »
The best power consumption on sleep I have achieved is ~170µA, nowhere near the 1µA@3.3V that is mention on the manual

That seems very high. What's your sleep code?
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #15 on: July 27, 2022, 12:31:20 am »
Just thought I'd throw this out there...

Does anybody here have a deepl account? Can you translate the datasheet using that and upload it here to see if it's any better?

https://www.deepl.com/translator

 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #16 on: July 27, 2022, 01:53:21 am »
Here's my sleep test code for the 328P.  It produces sleep current less than 1uA if the chip is a genuine 328P (not all are).  It works on a Pro Mini with regulator and LED removed.  I don't know if it's at all appropriate for this new chip.
 
Code: [Select]
#include <Wire.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
int i;

void setup(){

  for (i = 0; i < 20; i++) {          // all pins to one rail or the other
    pinMode(i,OUTPUT);
    digitalWrite(i,LOW);
  }
  ADCSRA = 0;                         // disable ADC for power saving
  wdt_disable();                      // disable WDT for power saving
  set_sleep_mode (SLEEP_MODE_PWR_DOWN); // Deep sleep
  sleep_enable();
  sleep_bod_disable();                // disable brownout detector during sleep
  sleep_cpu();                        // now go to sleep

}

void loop(){
}
 
The following users thanked this post: elecdonia, YurkshireLad

Offline rooppoorali

  • Regular Contributor
  • *
  • Posts: 100
  • Country: bd
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #17 on: July 27, 2022, 09:35:10 am »
Are they interchangeable? Can we write code for LGT8F328P using Atmel Studio and load the hex file using AVRdude? Just like the way we do with ATMega328?
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #18 on: July 27, 2022, 02:41:48 pm »
Ralph Bacon made a very good video on this chip a few years ago.



 
The following users thanked this post: elecdonia

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #19 on: July 27, 2022, 03:52:03 pm »
Here's my sleep test code for the 328P.  It produces sleep current less than 1uA if the chip is a genuine 328P (not all are).   I don't know if it's at all appropriate for this new chip.
 
Code: [Select]
#include <Wire.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
int i;

void setup(){

  for (i = 0; i < 20; i++) {          // all pins to one rail or the other
    pinMode(i,OUTPUT);
    digitalWrite(i,LOW);
  }
  ADCSRA = 0;                         // disable ADC for power saving
  wdt_disable();                      // disable WDT for power saving
  set_sleep_mode (SLEEP_MODE_PWR_DOWN); // Deep sleep
  sleep_enable();
  sleep_bod_disable();                // disable brownout detector during sleep
  sleep_cpu();                        // now go to sleep

}

void loop(){
}

Thanks. That doesn't prove it 100% though, there could be a problem in the libraries. Maybe a peripheral is left powered on or something.

It works on a Pro Mini with regulator and LED removed.

The best sort of Pro Mini.  :)
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #20 on: July 27, 2022, 03:54:35 pm »
Are they interchangeable? Can we write code for LGT8F328P using Atmel Studio and load the hex file using AVRdude? Just like the way we do with ATMega328?

The code is interchangeable, yes.

I can use one by selecting "Pro Mini" in the Arduino IDE so I guess the bootloaders are compatible, too.

The main differences are lack of EEPROM, no fuse bits, no ICSP (it has a JTAG-like interface for programming/debugging).

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #21 on: July 28, 2022, 11:54:00 pm »
Quote
Are they interchangeable?
Some of the instruction timings are slightly different.  (Several traditionally 2-cycle instructions only take one cycle.  Although this is also true of the newer AVRs, though.)
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #22 on: July 29, 2022, 06:45:59 am »
Quote
Are they interchangeable?
Some of the instruction timings are slightly different.  (Several traditionally 2-cycle instructions only take one cycle.  Although this is also true of the newer AVRs, though.)

And several traditionally 3-cycle instructions only take two cycles.
 

Offline rooppoorali

  • Regular Contributor
  • *
  • Posts: 100
  • Country: bd
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #23 on: July 29, 2022, 08:08:54 am »
Thanks for answering to my questions , dear all.
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #24 on: July 29, 2022, 08:21:31 am »
This doc has a comparison of the instructions that are faster.

Some of those will have a big impact on performance, especially the faster push/pop.

« Last Edit: July 29, 2022, 08:25:35 am by Fungus »
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #25 on: July 29, 2022, 08:26:07 am »
This doc lists the advantages:


« Last Edit: July 29, 2022, 08:36:18 am by Fungus »
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #26 on: July 29, 2022, 03:20:29 pm »
Given the descriptions, more chinese, definitely! :D
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline AndyBeez

  • Frequent Contributor
  • **
  • Posts: 856
  • Country: nu
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #27 on: July 29, 2022, 04:43:57 pm »
Barely known outside of China, these 'LG' ( LogicGreen ) chips exist mainly for deployment in dirt cheap Chinese consumer products: toys to appliances and to more toys. Don't expect the reliability or support of the original Atmel products. So avoid using in your self driving car project. Since chipaggedon started, these are being sold in arduino clone boards at arduino 'compatible' prices. If you want extras with documentation, play with STM32s.
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #28 on: July 29, 2022, 08:31:24 pm »
Barely known outside of China, these 'LG' ( LogicGreen ) chips exist mainly for deployment in dirt cheap Chinese consumer products: toys to appliances and to more toys.

Is that bad thing?

Who doesn't want a cheaper Arduino-compatible chip with extra timers, extra PWMs and a DAC for hobby use?
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #29 on: July 30, 2022, 02:12:19 am »
I created a DeepL account to re-translate the datasheet. It seems nicer in some areas, especially the diagrams.

Copy attached below.

Now let's see if I can really cancel the "subscription" before they charge me anything.  :popcorn:
« Last Edit: July 30, 2022, 02:17:54 am by Fungus »
 
The following users thanked this post: elecdonia, ADI8421

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #30 on: July 30, 2022, 02:49:35 am »
Remember you can do the same thing using Google translate, for free.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #31 on: July 30, 2022, 06:29:50 am »
Remember you can do the same thing using Google translate, for free.

Like in this post?  :)

https://www.eevblog.com/forum/microcontrollers/lgt8f328p-clone-of-atmega328-with-lots-of-extras-anybody-use-them/msg4248262/#msg4248262

I was just wondering if it would be any better.
 

Offline agarza

  • Newbie
  • Posts: 2
  • Country: mx
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #32 on: September 21, 2022, 03:00:46 am »

[/quote]

That seems very high. What's your sleep code?
[/quote]

This is the code I use to sleep.  On a ATMEGA328p the current is ~1µA.  On a LGT8F328P ~150µA. 
set_sleep_mode(SLEEP_MODE_PWR_SAVE);
TCCR2B = (1 << CS20) | (1 << CS22);

 // Wait until TC2 is updated
 while ((ASSR & ((1 << OCR2AUB) | (1 << OCR2BUB) | (1 << TCR2AUB) | (1 << TCR2BUB) | (1<< TCN2UB))));

 sleep_mode();    //sleep!


There are many other Power registers on the LGT8F328P.  I've tried several with no luck.
 
The following users thanked this post: elecdonia

Offline elecdonia

  • Frequent Contributor
  • **
  • Posts: 399
  • Country: us
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #33 on: December 29, 2022, 03:46:51 pm »
Given the rocketing price of AVR Aduinos, I've just been looking at these things...

https://www.aliexpress.com/wholesale?SearchText=LGT8F328P

The extra features are very interesting for a project I have in mind, both for the DAC and for the extra ALU.

I ordered a few (some purple, some green) and so far so good. They work just like Arduino in the Arduino IDE.
Regarding clone Arduino Nano boards with LGT8F328P MCU:

1) Green LGT8F328P Nano boards are the cheapest. They use the internal RC clock of the MCU.

I wonder how stable (or unstable) the internal RC clock frequency is in these new ultra-cheap MCU chips?
My experience with the “calibrated” internal RC oscillator in genuine Atmel AVR chips is that it is sufficiently stable enough for applications which don’t require precise timing.
A big advantage of internal RC clock is that MCU starts up much faster compared to using crystal oscillator. This is important for applications which must wake up quickly from a deep sleep state where the clock is shut down.

2) Purple LGT8F328P Nano boards have an actual 32MHz crystal for the oscillator. This is similar to nearly all other Nano boards which have a genuine ATmega328 MCU, except the clock crystal for the purple LGT8F328P is 32MHz rather than the 16 or 8MHz crystal found in ATmega328 Nano boards.

3) After using many clone Nano and Arduino-pro boards that came with a genuine Atmel ATmega328 MCU, I must warn users that the Arduino clone board manufacturers use the very cheapest LDR voltage regulator chips. Many of these can tolerate only 9V maximum input voltage. I fried several clone Nano boards by applying 12V. I developed a habit of changing the voltage regulator chips for applications where the raw power input voltage might exceed 9V.

« Last Edit: December 30, 2022, 06:34:24 pm by elecdonia »
I’m learning to be a leading-edge designer of trailing-edge technology.
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #34 on: December 30, 2022, 07:42:48 am »
I wonder how stable (or unstable) the internal RC clock frequency is in these new ultra-cheap MCU chips?

The datasheet say's they're laser-trimmed at the factory. The frequency seems very accurate on the few chips I've measured.

2) Purple LGT8F328P Nano boards have an actual 32MHz crystal for the oscillator. This is similar to nearly all other Nano boards which have a genuine ATmega328 MCU, except the clock crystal for the purple LGT8F328P is 32MHz rather than the 16 or 8MHz crystal found in ATmega328 Nano boards.

Yep. I'm not sure what the advantage of the crystal is.

The main advantage of the purple ones is the built-in CH340 USB interface.

(although that's a bad thing for low-power projects).

I've gone through a few dozen of the green ones lately and not had any problems.
 
The following users thanked this post: elecdonia

Offline elecdonia

  • Frequent Contributor
  • **
  • Posts: 399
  • Country: us
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #35 on: December 30, 2022, 06:45:24 pm »
I wonder how stable (or unstable) the internal RC clock frequency is in these new ultra-cheap MCU chips?
The datasheet say's they're laser-trimmed at the factory. The frequency seems very accurate on the few chips I've measured.
2) Purple LGT8F328P Nano boards have an actual 32MHz crystal for the oscillator. This is similar to nearly all other Nano boards which have a genuine ATmega328 MCU, except the clock crystal for the purple LGT8F328P is 32MHz rather than the 16 or 8MHz crystal found in ATmega328 Nano boards.
Yep. I'm not sure what the advantage of the crystal is.
The main advantage of the purple ones is the built-in CH340 USB interface. (although that's a bad thing for low-power projects).

I've gone through a few dozen of the green ones lately and not had any problems.
Thanks for the info!

Revised features of green vs. purple LGT8F328P Arduino clones:
     Green board resembles traditional Arduino Pro:  Very small PC board without USB. MCU clock is internal factory-trimmed clock oscillator
     Purple board resembles Arduino Nano: USB interface included. MCU clock is crystal on PC board
I’m learning to be a leading-edge designer of trailing-edge technology.
 

Offline ADI8421

  • Newbie
  • Posts: 5
  • Country: nz
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #36 on: January 11, 2023, 06:34:04 am »
Hi Fungus,

I've taken an interest in writing code for these in assembly language too.
A brief video of my DAC test here:

Cheers Jim
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #37 on: January 11, 2023, 02:24:58 pm »
Hi Fungus,

I've taken an interest in writing code for these in assembly language too.

 :)  :-+

A brief video of my DAC test here:

The DAC works great at audio frequencies.
 

Offline ADI8421

  • Newbie
  • Posts: 5
  • Country: nz
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #38 on: January 13, 2023, 04:34:23 am »
Yes, the audio is pretty good. The data sheet advises an opamp buffer should be used on the DAC output, but it works OK into a Tecsun radio's Aux input without one.
 

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #39 on: January 13, 2023, 06:28:51 am »
Yes, the audio is pretty good. The data sheet advises an opamp buffer should be used on the DAC output, but it works OK into a Tecsun radio's Aux input without one.

No surprise, an aux input will be high impedance just like an op-amp.
« Last Edit: January 13, 2023, 05:50:54 pm by Fungus »
 

Offline yurishnol

  • Newbie
  • Posts: 1
  • Country: il
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #40 on: March 01, 2023, 02:11:25 pm »
Hi, this is about measure of VCC.
The bug (?) in board support lib package - currently Larduino_HSP_v3.6c still has it.
To measure VCC, one can use internal mux channel to internal VRef=1.024V (default),
by A/D reference=VCC, default.  analogReference(DEFAULT);
uint16_t AtoD = analogRead(IVREF); // IVREF=27 for lgt8f
Then, calculate VCC=(1.024/AtoD)*4096; //Volt.
 or else, VCC=4194304/AtoD,mV. (0x400000/AtoD)
For original AVR' 328p, instead of 4096 use 1024, for AtoD is 10 bit.
Currently, for lgt8f the code do not work, analogRead(IVREF) returns 0..2.
To fix the problem, need set the bit BGEN, bit7 in register ADCSRD,
 ADC Control Status Register D.
e.g.: ADCSRD = 0x80;
Then, AtoD of IVREF: uint16_t AtoD = analogRead(IVREF);
 will return correct value. e.g.:
for VCC=3.36 V, analogRead(IVREF) returns 1249. VCC=1.024/1249*4096=3.358V
for VCC=4.72 V, analogRead(IVREF) returns 889.  VCC=1.024/889*4096=4.718V
 
The following users thanked this post: Fungus

Offline Gjeskog

  • Newbie
  • Posts: 1
  • Country: no
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #41 on: March 11, 2023, 04:00:49 am »
Hi all. I'm one of those idiots taking an interest in these LogicGreen microcontrollers, so I ordered a bunch a while back. And out of frustration with not having a proper manual to learn from, I set out to translate the manual for this chip. I have used Google, but in small chunks to be able to properly recreate context and readabillity.

Personally I'm pretty pleased with the result, allthough it's not yet properly proofread, but I'm thinking this might be of some interest for others with simmilar interest in cheap Chinese MCUs.

https://github.com/Skogmus/Datasheet_translations/tree/main/LGT8FX8P_databook_v1.0.5

Have a look at it, and feel free to pitch in corrections if you feel like it.
 
The following users thanked this post: PeterG, paf, Fungus, elecdonia, GromBeestje, IOsetting

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #42 on: March 11, 2023, 05:50:01 pm »
Hi all. I'm one of those idiots taking an interest in these LogicGreen microcontrollers, so I ordered a bunch a while back. And out of frustration with not having a proper manual to learn from, I set out to translate the manual for this chip. I have used Google, but in small chunks to be able to properly recreate context and readabillity.

That's awesome, especially the diagrams and tables. The machine translators really made a mess of the diagrams/tables when I tried them.

 :-+ :-+ :-+ :-+ :-+
 
The following users thanked this post: Gjeskog

Offline FungusTopic starter

  • Super Contributor
  • ***
  • Posts: 16670
  • Country: 00
Re: LGT8F328P - clone of ATMega328 with lots of extras!
« Reply #43 on: March 11, 2023, 05:52:37 pm »
FWIW I've used a lot of these lately. I'm pretty much doing all my gadgets using them and haven't had any problems.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf