2

This is my board MKS Melzi v2.0 cloned

MKS Melzi v2.0 cloned

I replaced the MCU (the actual IC) with new ATmega1284P 16 MHz, because the old MCU was damaged - the reason was that the fan got dusty and the power line became unstable. I replaced the MCU with the exact same model.

I have tried to flash it many times using usbasp. It works but same issue system menus boot splash are still so slow it's painful. It takes minutes on an old Marlin version 1.1.6, hours on a new Marlin 2.x

I think it's something related to MCU (crystal oscillator frequencies). Maybe the system uses an internal crystal so the MCU got stuck.

  1. How can I switch to an external crystal?
  2. If it's not, then what can cause the problem?

Firmware links:

Greenonline
  • 5,831
  • 7
  • 30
  • 60
ioen jid
  • 43
  • 5
  • Just as a note, Your board looks like a clone of the Zonestar ZRIB v2 mainboard, which derives from Melzi – craftxbox Aug 16 '21 at 12:45

1 Answers1

1

Either:

  • You have a clock prescaler set, or;
  • You are not using the external oscillator on the board.

There are some internal fuses that set the clock frequency divider and the clock source and maybe your new IC has the incorrect fuses set.

That is to say, they may be factory default, but they are not the same as the controller board comes shipped with.

You probably want to check both settings as the factory defaults of your replacement IC are probably not what you expect, or desire.

Check the ATmega1284P datasheet for details.


Prescaler

Section 7.12.2 CLKPR - Clock Prescale Register, page 38. That is for the general clock frequency, and shows the register CLKPR in particular Bits 3:0.

7.12.2 CLKPR - Clock Prescale Register

Or section 7.11 System Clock Prescaler

7.11 System Clock Prescaler

External clock

Section 7.2 Clock Sources, shows that CKSEL Bits 3:0 set which clock is used, internal or external. You presumably want to use the external clock so set all four bits to zero

7.2 Clock Sources


To set, or examine, any of the registers, you have to use usbasp. I can't remember what the commands are. If you look on SE.Arduino or SE.Electronics I am sure that there is a question with the answer. I vaguely remember having the same problem with an ATtiny.

Greenonline
  • 5,831
  • 7
  • 30
  • 60
  • 1
    I tested by using this command `avrdude -c usbasp -patmega1284p -U lfuse:w:0b01100000:m` default value is 0x62 = 01100010 so I changed bits 3:0 to zero new value 0x60 = 01100000 and the MCU no longer responds. – ioen jid Aug 14 '21 at 08:57
  • Is there a jumper that you need to make, in order to apply the external clock? Maybe that is missing. There is clearly a 16 MHz crystal on the board. Can you check (with an oscilloscope) whether there is a clock signal, *both* from the crystal and on the MCU clock pin? Otherwise, the solution isn't easy. While the chip is not dead, you will need to apply an external clock, see [this post](https://www.avrfreaks.net/forum/tutsoft-recovering-locked-out-avr). You might have to remove the SMD, or add a wire to a clock, external to the whole board, using a 555 timer, for example. – Greenonline Aug 14 '21 at 09:56
  • I can't see a jumper pin for clock select, looking at the image in [this PDF](https://github.com/makerbase-mks/Datasheet/blob/master/Chinese%20datasheet/MKS%20MELZI%20V2.0%E6%95%B0%E6%8D%AE%E6%89%8B%E5%86%8C.pdf), it seems to be "hard wired". Maybe check that the CLOCK line is soldered correctly, by visual examination, and by checking with a oscilloscope. It just sounds like there isn't an external CLOCK signal getting through. Check the clock circuit, maybe the crystal, or the pair of 22 pF capacitors (`C11`), or other supplementary components (`C14` or `R24`) are damaged? – Greenonline Aug 14 '21 at 10:02
  • 1
    I replaced the crystal with a new one and checked the line - that's all connected but same issue. My board is a little bit different from the original, so I don't have `C11` `C14` `R24`. Its produced by Tronxy "cxy v.2-0508". I have two capacitors on crystal pintout each leg have one here [link](https://www.tronxyonline.com/Tronxy-Ramps1-4-Update-Version-3D-Printer-Reprap-mainboard-CXY-V-2-p69319.html) of Tronxy page – ioen jid Aug 15 '21 at 04:55
  • It is difficult to see the component names/numbers from either your photo and the photo in the link, but there seem to be two resistors (next to each other) and two capacitors on the other side (in a line). Apart from checking to see if the components (R and C) are good, you would need to see if there is a clock signal using a oscilloscope to see what is really happening - otherwise we are just guessing. Either that, or apply an external clock source to get the MCU running, so that you can flash it back to using the internal clock again (`0x62`). Then you could check the prescaler setting. – Greenonline Aug 15 '21 at 05:38
  • If the MCU is set back to using the internal clock, then the speed will be 8 MHz so am I supposed to flash Marlin using `1284p` with `8 MHz` option not `16 MHz`, right ? On the oscilloscope, the signal looks weird, it is not a square signal. The only hope to ask Tronxy for help. i will update with a solution soon – ioen jid Aug 15 '21 at 08:42
  • 1
    The internal clock speed will be determined by the prescaler value. Did you check to see what that was, before setting the fuses for the external clock? The waveform would not be square, if there are capacitance issues (leakage etc.). Maybe one of the tracks on the PCB has been damaged? Could you post a **new question** about the missing external clock (as your original question has been answered, this is a new question), and add a photo/screenshot of the scope output, showing the waveform? In the new question, refer back to this question, using the URL of this question, as they are related. – Greenonline Aug 15 '21 at 09:51
  • 1
    You need to ask a *new question* for the new issue of the missing clock. Once you open a new question, I can copy over the information from these comments for you. Many thanks in advance. – Greenonline Aug 15 '21 at 10:10