Forbiden tech from China has arrived :-)

Go To Last Post
139 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Something very weird just happened I can't edit, please delete the above post, and this one.

I bet I know what.  You copied __DELAY_BACKWARD_COMPATIBLE__ from the online AVR Libc docs, and tried to paste into a forum post.  The docs use a BBcode-like formatting which employs square brackets.  The forum software will happily display it correctly once posted, but the editor Javascript will not.  You paste, but see nothing.  It's there, so when you click post, it appears.

 

I guess you pasted a few times, wondering why you couldn't see it... ;-)

 

Blame the saxophone players.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeap, it was exactly that cheeky

But anyway, __DELAY_BACKWARD_COMPATIBLE__ combined with editing this line:

__tmp2 = ((F_CPU) / 4e6) * __us;

replacing 4e6 by a define that can be 4e6 for normal AVRs or 3e6 for LGT AVRs would work and it's just a minor edit.

 

edit: well, for _delay_us at least... _delay_ms also needs edits.

Last Edited: Thu. Sep 28, 2017 - 11:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As the timing is actually delivered by __builtin_avr_delay_cycles(), that is what should be modified.

 So ... what would be the procedure/logistics for getting separate "clone" CPUs that are "almost like X" added to avr-gcc ?  Atmel (Microchip) is more-or-less gatekeeper of new devices for avr-gcc, right?

SBIW is not the only timing difference with these chips; I'll bet that things like VUSB and Atomic Zombie's video code break as well...

 

(BTW: these are very good observations - thank you for poking around at the chip!)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have found what seems to be another Arduino clone based on the LGT AVR clones <- Too much cloning going on :P

 

These are called "MassDuino" and the MCU is the "MD-328D" but I think it's just a re-branded LGT8F328D.

http://www.inhaos.com/index.php

https://www.aliexpress.com/whole...

 

They seem to be better quality boards than the ones mentioned in this thread. Maybe I'll buy one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would be interested in the boards with proper Uno headers.

None of the items seem to be available from the Ebay links.

I have ordered the Uno clone from AliExpress.

 

Yes,  I suspect that they use the LGT8F328D chip (or similar)

The LGT8F328P chip is a lot more attractive.

Both -D and -P give less than 32kB Flash.   It is worth removing the EEPROM "functionality" if you want reasonable Flash program storage.

 

I know that you have the 328P breakout board i.e. like a Nano.

 

Do you want a 328D breakout board?   i.e. like a Pro-Mini  (needs external USB Serial)

I can mail one to you.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

 

Do you want a 328D breakout board?   i.e. like a Pro-Mini  (needs external USB Serial)

I can mail one to you.

 

 

Thanks, but actually I have one of those too. It's the one in post #55, right? Maybe someone else would like to have it for testing?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

These are called "MassDuino"

No religious topics please. cheeky

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@El Tangas,

 

Have you tried bidirectional SPI?

 

My MassDuino Uno LC board arrived a couple of days ago.

 

It contains an LGT8F328D and works nicely at 3.3V

 

I am trying to get Bidirectional SPI Master to work.   i.e. setting DUAL bit in SPCR.

My Logic Analyser shows the MOSI line becoming an input but reading SPDR returns the wrong values.

 

I get the same values and behaviour with LGT8F328P

The 328P has other features with its SPI buffers.

 

Bidirectional SPI on a STM32 is also painful.   This seems crazy.   Bidirectional only involves changing MOSI from output to input and routeing the MISO signal to this pin.    Writing to SPDR sends 8 SCK clocks.

 

David.

Last Edited: Fri. Jan 26, 2018 - 11:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, I haven't tested that. You mean 3-wire SPI, that is, clock, select and a single bidirectional data wire?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes.   As used by ST7735, ILI9163, ... and an option for most TFT controllers.

 

Oh,  I struggled for ages to read the BandGap.    You have to enable ACBG for the BandGap to be accessible to the ADC input multiplexer.

Mind you,  the LGT has a "better" method of reading AVCC via a potential divider.   Instead of the AVR method of reading BG with AVCC as ref.

 

If the chips had a usable 32kB of Flash,   both 328D and 328P would be very attractive.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

#113 Do you really use more than 30K of code? (it must be fonts!?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes,   fonts,  bitmaps, ... take a massive amount of flash memory.

 

My standard Arduino library demo sketch needs to use every class method.

I can reduce binary size by:

Eliminating calls to the String class.

Removing any f-p maths.

Eliminating calls to Serial class.

Removing or reducing size of bitmaps.

 

Since my library is designed for Uno-style shields I would like to fit the same demo on Duemilanove, Uno, Leonardo, MassDuino, (LogicGreen), ...

The Leonardo and Duemilanove have very big bootloaders but are not very common targets.

 

Obviously there are no size problems with Mega, Zero, Due, STM32, Teensy3.x

 

Yes,  I quite agree.   Simple apps are unlikely to use every class method.

And any human would avoid the Arduino String class like the Plague.

 

SPI on a single bidirectional SDA pin is used by many integrated circuits.   Even regular 3-Wire chips tend to have MOSI sequences followed by MISO sequences.   If the SPI Slave has low traffic it is fine to bit-bash in software.

 

But Display controllers have enormous traffic.   Hence the interest in Hardware SPI.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From what I understand from google translate of the datasheet, the "dual" mode means that bits are read from both MOSI and MISO with each clock. The master cannot send data in this mode.

So this is not actually a bidirectional mode, I'm not sure which kind of devices use this protocol? Some EEPROMs, I think.

 

Host two-wire receiver
The SPI module's two-wire mode is valid only in host operating mode. Unlike the one-wire mode, both MOSI and MISO are used by the host to receive data. Each SPCK clock receives two bits of data simultaneously (before the data on the MISO line, MOSI line data in the post), after receiving two bytes of data, the hardware sets the transfer completion flag SPIF, the data is saved to the receive buffer and shift register.
At this point the software must read the SPDR register twice to get the two bytes of data it receives.
It should be noted that although the host does not send data to the slave in 2-wire mode, the software still needs to write data to the SPDR register to start the clock generator to generate the communication clock. Once the SPDR register is written, it can receive two bytes of data

Last Edited: Tue. Jan 30, 2018 - 02:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would expect the DUAL bit to:

1.  change MOSI pin from output to input

2.  disconnect MOSI

3.  connect MISO

4.  write SPDR starts SCK

5.  read SPDR reads RX buffer

 

This would mean any write to TX e.g. SPDR = 0 to still instigate the SCK pulses

And any read from RX e.g. reply = SPDR would read the RX buffer

 

Observing the MOSI pin with a Logic Analyser shows that (1) is as expected.

(2) is as expected.

(4) is as expected

(5) returns consistent values but they bear no relation to the data from the Logic Analyser.

 

All operations on 25xxxx EEPROMs are half-duplex.

All operations on SD Cards are half-duplex

All operations on TFT controllers are half-duplex

 

ICSP via SPI on AVR chips are full-duplex.   i.e. you require separate MOSI, MISO lines

 

Since the AVR SPI peripheral has inherent haywire-ability the hardware is capable of (1), (2), (3) but it only does this with the MSTR bit

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have MISO and MOSI connected together (shorted?), right?

 

So see what happens if you send 8 bits of data: 0bx7x6x5x4x3x2x1x0, I expect that SPDR will have 2 bytes available for reading. These bytes will be: 0bx7x7x6x6x5x5x4x4 0bx3x3x2x2x1x1x0x0, that is, all bits will be doubled because they are read alternately from MOSI and MISO, which will be the same since they are shorted.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, I just have AVR MOSI connected to SDA on the ST7735
The whole poit of half-duplex is to reduce the number of lines.
.
I tried your theory of 16 alternate bits but this does not work. It would also mean hard work to extract the 8-bits.
And there is no point in keeping track of a TX signal that is disconnected.
.
I am sure there is a simple explanation but I see no mention in the Chinese Forum. And the -P works the same as the -D version.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thought you were doing this:

 

 

That is: on output, MOSI sends data, that is echoed in MISO, SPDR is read and discarded. Then MOSI becomes high impedance for the input phase, you write a dummy byte so that SCK sends pulses, and data is received by MISO.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No.   I just had TFT_SDA  connected to AVR_MOSI.    In a perfect world,  I could use the DUAL bit in LGT's SPSR to swap sides in half-duplex.

 

I also tried this form of connection.   i.e. TFT_SDA connected to AVR_MOSI via 10k resistor with AVR_MISO

This arrangement looks as if it should work with any SPI peripheral on any MCU.    The MCU MOSI would win when in TX direction.   The Slave SDA would win in the RX direction.    I can always put the MOSI port driver to input in the RX phase if I need to.  

enter image description here

 

This is what I get for reading 3 bytes from reg(0x04).    The MISO line samples the MOSI line in the TX phase.   The MOSI and MISO lines just go high in the RX phase.

 

and this is what I get without linking MISO i.e. how the ST7735 behaves in real life when presented with a reg(0x04) RDID4 command:

 

 

Ignore the MISO trace in the "unlinked" picture.   The line is floating and just picks up noise.

I can go back to bit-bashing in software but it would be so nice to use the hardware as Nature intended.

 

David.

Last Edited: Tue. Jan 30, 2018 - 02:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A translation that was completed yesterday :

GitHub - RalphBacon/LGT8F328P-Arduino-Clone-Chip-ATMega328P: An improved ATMega328P with this cheap clone Logic Green LGT8F328P

...

 

[download a 2.7MB PDF]

A dual Chinese/English translated datasheet - better than the other one

 

...

via

#156 LGT8F328P Replacement for ATMEGA328P (at 32MHz 😲) (YouTube, Aug 2 2019, 26m14s)

by Ralph S Bacon

There are more manufacturers of LogicGreen AVR function-like boards.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone,

 

I have a lgt8f328p and accidentally disabled the reset pin, now I can't program it.

 

From what I understood I need to program it through SWD, I found this guide:

 

https://www.itead.cc/blog/instal...

 

Is this correct or is there an alternative? If this was an ATmega328p I could program it with a High Voltage Programmer but with the lgt8f328p I don't think that's possible because I can't find information about it.

 

Thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should be able to re-install the Bootloader with LarduinoISP.ino sketch running on a regular Arduino.

 

Which LGT board do you have?

Do you own an Arduino?

 

Your Itead link is fairly ancient.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a WAVGAT UNO R3 (lgt8f328p) ,

 

https://www.aliexpress.com/item/...

 

and I have an Arduino Mega2560 (atmega2560).

 

Ok doesn't it use the reset?

 

https://github.com/LGTMCU/Lardui...

 

EDIT: I took a look at the code,

 

  digitalWrite(RESET, HIGH);
  pinMode(RESET, OUTPUT);
  delay(20);
  digitalWrite(RESET, LOW);
  
  SWD_init();
  SWD_Idle(10);

I don't think this will work. I am not an expert, so I hope I am wrong.

Last Edited: Wed. Sep 4, 2019 - 07:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ypur WAVGAT board seems to have a chip called AVGA328P.

I don't see any SWC, SWD pins.  Nor PC6, PC7 pins
 

Note that most Chinese boards seem to have scrubbed the chip marking.

Does this have a LGT8F328P-32 chip ?

I am wary of chips with scrubbed markings.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well it's a LGT8F328 because when I download the folder hardware for the Arduino IDE it contains information for that chip.

 

Right now I am not home but I will check which package is that chip.

 

Yes, this board was a mistake, I never thought they would clone the Atmega328p.

 

EDIT: Yes, it's a LGT8F328P-32.

Last Edited: Wed. Sep 4, 2019 - 10:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The WAVGAT board seems to be 5V GPIO only.   Many other boards have a switch for 3.3V/5V GPIO.

And without any SWC, SWD headers will be difficult to re-program.

 

First off.   Try the bootloader via avrdude e.g.

avrdude -c arduino -p m328p -P com5 - b 57600

Change the com5 for the actual COM#.   Most LGT bootloaders are 57600 baud.   Try 115200 baud too.

Your WAVGAT has a crystals on the pcb.   So I would expect accurate baud rates.

 

If the bootloader is running on the RC you might need to tweak the baudrate.

My LGT8F328P-48 needs -b59000 for reliable bootload.

 

If you don't have any luck with the bootloader,   you will have to solder fine wires to the SWC, SWD pins on the TQFP32 chip and use LarduinoISP.ino sketch to restore the Bootloader.

 

If the WAVGAT board had a 3V GPIO switch I would buy one.   I have little interest in a 5V GPIO.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok thank you David,

 

I always programmed the board with avrdude and it always worked like a charm.

 

The problem is that I accidentally disabled the reset function. Unlike ATmega328p, in the LGT8F328P

I can modify the reset pin, select extern or internal clock, etc in the main function, you don't use fuses.

 

So I think my problem right now is that I cannot program the chip because I don't have a reset function.

 

Besides that, the problem with SWD and SWC is that I don't find documentation about it for this chip, so I am not even sure if I bought the programmer this would solve my problem. I just bought another Arduino Uno.

 

Anyway, I would like to solve this problem, it's a shame to have a board that I cannot use. And this chip theoretically has some cool features.

 

I am not an expert, so I may not being clear or not using the right words, please if I need to clarify my sentences just tell me

 

Thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please just try avrdude.   And write notes on paper.

 

Then you can document what steps you have taken,  and with what result.

 

As far as I know you can't disable the RESET pin.

 

I presume tht there is a current sketch running on your board.

What happens if you press the RESET button?

 

You don't need any complex hardware.   Just solder a 30AWG wire to SWC and SWD pins of the TQFP32.   (e.g. wirewrap wire is 30AWG )

 

David.

 

p.s. there are 4 holes near the CH340 chip.   What do they do?

They might be SWD, SWC, PC6, PC7

Much easier to mount header pins than soldering fine wires.

Last Edited: Thu. Sep 5, 2019 - 12:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will try the avrdude. If that fails I will solder the wires to SWC and SWD, but after that, I don't know what to do.

 

I attached a pdf file, page 57, changing the PMX2 register I can disable external reset,

 

    uint8_t btmp = PMX2 | (1 << C6EN);
    PMX2 = 0x80;
    PMX2 = btmp;

My current sketch is a simple blinking led,

 

int main(void) {

    sysClockSource(EXT_OSC);
    sysClockPrescale(SYSCLK_DIV_0);
    sysEXRESETDisable();

    /* Replace with your application code */
    DDRB = 0b11111111;
    PORTB = 0b00000000;

    while (1) {
        PORTB ^= 1 << LED_BUILTIN;
        _delay_ms(1000);
    }
}

That 4 holes are connected to the CH340.

 

EDIT: I forgot to say that the reset button does nothing. Before I disabled the external reset it worked fine.

Attachment(s): 

Last Edited: Thu. Sep 5, 2019 - 01:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can only do this in software e.g.

    uint8_t btmp = PMX2 | (1 << C6EN);
    PMX2 = 0x80;
    PMX2 = btmp;

A Power On Reset will still work.   Of course the pin will be disabled as soon as your sketch starts running (and executes the PMX2 sequence)

 

You should hold the Reset button down as you supply power.

An external programmer will control the Reset button.

 

I suspect that you can run the bootloader in the same way.   i.e. force a Power-On reset instead of a pin-Reset

But it might take some nimble fingering.

 

I think it will be safer to use LarduinoISP after you have connected the SWC, SWD pins.

 

At least PMX2 should be recoverable with low voltage.

Punters generally enable the AVR RSTDISBL fuse.   Which requires HVPP to recover.   (AVR users have an overwhelming desire to shoot their own feet)

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I ran a script and tried these baud rates, 

 

BAUD_LIST=('2400' '4800' '9600' '14400' '19200' '28800' '38400' '57600' '59000' '76800' '115200' '230400' '250000')

 

Always with the same result,

 

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding

 

Ok so,

- Solder wires to SWD and SWC pins

- Connect those pins to Arduino Mega, pin 12 and 13.

- Upload LarduinoISP.ino sketch to Arduino Mega

- Using Arduino IDE burn bootloader to the WAVGAT UNO board

 

Do I have to hold reset when I connect WAVGAT board to Arduino Mega and only release it after I start programming it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First off,   power up your WAVGAT with Reset button held down.    The blink should not start.

Then power up normally.   The blink should blink.

 

I will dig out my LarduinoISP.   I am sure that I wrote some significant improvements (in 2017)

I need to find  it first !!

 

David.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, it's exactly like you said, if I hold the reset button when I connect the board to power, the blink won't start. After I release the reset button, the led starts blinking as expected.

 

Ok ok thank you very much

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nice. Now you have a chance, as soon as you release the RESET button, the bootloader will wait for commands for a short while so you need to run avrdude at about the same time as you release the button.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By hand it's impossible to sync.

 

I was hoping with larduino sketch to reach something like that but by software.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1.  File->Preferences: Verbose Compile

2.  write a FastBlinky i.e. without PMX2 sequence  and different speed to your current Blinky

3.  plug in the WAVGAT with the Reset button held down.

4.  click on [Upload] icon

5.  watch the build lines.

6.  when it says "Global variables use NNN bytes" release the button

7.  if successful the FastBlinky should upload and run.    Reset button should stop it.

 

8.  it is worth trying a few times until successful.   Much easier than soldering wires to a TQFP.

Last Edited: Thu. Sep 5, 2019 - 05:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok I will try that.

 

I already soldered the wires

 

EDIT: I am uploading the sketch through the terminal, so I assume that as soon as I press "Enter" to execute the command I should release the reset button.

It's not working, I already tried different delay (release the button) but it doesn't work.

EDIT2: I added on the larduino sketch,

 

  pinMode(10, OUTPUT);
  delay(20);
  digitalWrite(10, LOW);

to keep WAVGAT under reset till I hit the button to program it through Arduino Mega. It didn't work.

Last Edited: Thu. Sep 5, 2019 - 06:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Board Package for Logic Green LGT8F328x and LGT8F88D via Boards Manager Urls. The easy way :)

https://github.com/dbuezas/lgt8fx
 

  • Support 32 Mhz and other clock speeds via menus with automatic prescaler setup
  • Differential Amplifier API
  • Better Boards Menu
  • Installation via Board Manager Urls
  • Added SoftwareSerial @32Mhz
  • This is based on their "old" more compatible version LarduinoHSP v3.6

 

Did it mostly for myself, I hope others find it useful.

 

Add LGT8fx support to the Arduino IDE via Boards Manager Urls:
https://github.com/dbuezas/lgt8fx

Pages