Forbiden tech from China has arrived :-)

Go To Last Post
121 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.

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

You are only quibbling over the LGT target that you have never even used.

Never used, true.  Quibbling, false. ;-)

 

__DELAY_BACKWARD_COMPATIBLE__

That doesn't fix anything.  No matter how many times you define it ;-)

 

All it does is avoid the use of __builtin_avr_delay_cycles() in favour of _delay_loop_1() and _delay_loop_2().  The latter still relies on the use of sbiw, and the 'fact' that it takes two cycles.  Only _delay_loop_1() avoids sbiw, and is only used by _delay_us() for very short delays (less than 256 loops, or 'ticks', at F_CPU).

 

It's all a tempest in a teapot.  I only started down this road when @ki0bk joked about faking F_CPU, and I responded while acknowledging the joke.  I don't really care one way or the other, since as David points out I haven't used the LGT, nor am I likely to.

"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."

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

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

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

 

  • 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."

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

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"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

Pages