MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.19k stars 19.22k forks source link

[BUG] Mega1284p based devboard freeze up, not responding to encoder. #26468

Closed syriloak closed 10 months ago

syriloak commented 10 months ago

Did you test the latest bugfix-2.1.x code?

No.

Bug Description

Description: Marlin freeze up after half a minute. Not responding to Encoder, not reading temp.

Board: I've designed my own board. MCU: Atmega1284P tested with 8MHz int. osc 16,20,32MHz external crystal. Pin assignment: -PA0(ADC0) : Hotend sensor(4k7 to 5V, 100k sensor) -PA1(ADC1): Heated bed sensor (4k7 to 5V, 100k sensor) -PA2: X Limit switch (4k7 to GND) -PA3: Y Limit switch (4k7 to GND) -PA4: Z Limit switch (4k7 to GND) -PA5: Inductive or Capacitive sensor (4k7 to GND) -PA6: SD-Detect -PA7: SD-SS

-PC0: I2C SCL (4k7 to 5V) for SSD1306 OLED -PC1: I2C SDA (4k7 to 5V) for SSD1306 OLED -PC2: Z DIR (4k7 to GND) -PC3: Z STP (4k7 to GND) -PC4: Y DIR (4k7 to GND) -PC5: Y STP (4k7 to GND) -PC6: Z DIR (4k7 to GND) -PC7: Z STP (4k7 to GND)

-PD0: RXTTL (for RS232-USB) -PD1: TXTTL (for RS232-USB) -PD2: ENA E (4k7 to GND) -PD3: ENA Z (4k7 to GND) -PD4: ENA Y (4k7 to GND) -PD5: ENA X (4k7 to GND) -PD6: E DIR (4k7 to GND) -PD7: E STP (4k7 to GND)

-PB0: BTN-ENC (4k7 to 5V) Encoder button -PB1: BTN-EN1 (4k7 to 5V) Encoder A -PB2: BTN-EN2 (4k7 to 5V) Encoder B -PB3: Heated bed PWM (OC0A) -PB4: Hotend PWM (OC1A) -PB5: MOSI (for SD CARD) -PB6: MISO (for SD CARD) -PB7: SCK (for SD CARD)

To prevent false bug report PB0,PB1 and PB2 pins were tested with a small C program, the MCU is not faulty.

pins.h modified to allow custom motherboard selection:

elif MB(XVORTEX)

include "sanguino/pins_XVORTEX.h"

// ATmega644P, ATmega1284P env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p

Archive.zip

Bug Timeline

After the first compile. No previous history.

Expected behavior

Expected to not freeze up after ~30sec, read encoder & encoder button properly.

Actual behavior

Unable to enter menu, not responding to encoder, freeze up.

Steps to Reproduce

Compile, upload, be sad.

Version of Marlin Firmware

Unable to enter menu. According to the download page it is v2.1.2.1

Printer model

Carthesian, unique.

Electronics

Unique.

LCD/Controller

SSD1306 I2C 128x64 OLED

Other add-ons

No response

Bed Leveling

None

Your Slicer

None

Host Software

None

Don't forget to include

Additional information & file uploads

Currently no bed leveling is enabled, but planning to do if this issue resolved.

ellensp commented 10 months ago

removing all the comments so you cant do a diff to see what has been changed in config is not nice.

define U8GLIB_SSD1306 is just a display, not a display + encoder

use a SAV_3DGLCD or something similar

https://reprap.org/wiki/SAV_OLED

fully populated Configuration.h Configuration.zip

ellensp commented 10 months ago

Your current pins as provided. Do not match your description

You have conflicts on pin 0 and pin 1

Even if you never turned on the heaters, the firmware still initializes the pins BTN_EN1 is an input HEATER_0_PIN s an output Which ever one was set last will be what it is set to

/**
 * PIN:   0   Port: B0   BTN_EN1
 *                       HEATER_0_PIN         <---     In error 
 * PIN:   1   Port: B1   BTN_EN2
                         HEATER_BED_PIN       <---     In error 
 * PIN:   2   Port: B2   BTN_ENC
 * PIN:   3   Port: B3                        <---     In error should be HEATER_BED_PIN
 * PIN:   4   Port: B4                        <---     In error should be HEATER_0_PIN
 * PIN:   5   Port: B5   AVR_MOSI_PIN
 * PIN:   6   Port: B6   AVR_MISO_PIN
 * PIN:   7   Port: B7   AVR_SCK_PIN
 * PIN:   8   Port: D0   RXD
 * PIN:   9   Port: D1   TXD
 * PIN:  10   Port: D2   E0_ENABLE_PIN
 * PIN:  11   Port: D3   Z_ENABLE_PIN
 * PIN:  12   Port: D4   Y_ENABLE_PIN
 * PIN:  13   Port: D5   X_ENABLE_PIN
 * PIN:  14   Port: D6   E0_DIR_PIN
 * PIN:  15   Port: D7   E0_STEP_PIN
 * PIN:  16   Port: C0   SCL
 * PIN:  17   Port: C1   SDA
 * PIN:  18   Port: C2   Z_DIR_PIN
 * PIN:  19   Port: C3   Z_STEP_PIN
 * PIN:  20   Port: C4   Y_DIR_PIN
 * PIN:  21   Port: C5   Y_STEP_PIN
 * PIN:  22   Port: C6   X_DIR_PIN
 * PIN:  23   Port: C7   X_STEP_PIN
 * PIN:  24   Port: A7   TEMP_0_PIN               <-----   description says SD-SS
 * PIN:  25   Port: A6   TEMP_BED_PIN             <-----   description says SD-Detect
 * PIN:  26   Port: A5   X_STOP_PIN               <-----   description says Z_MIN_PROBE_PIN
 * PIN:  27   Port: A4   Y_STOP_PIN               <-----   description says Z_STOP_PIN
 * PIN:  28   Port: A3   Z_STOP_PIN               <-----   description says Y_STOP_PIN
 * PIN:  29   Port: A2   Z_MIN_PROBE_PIN          <-----   description says X_STOP_PIN
 * PIN:  30   Port: A1                            <-----   description says TEMP_BED_PIN
 * PIN:  31   Port: A0                            <-----   description says TEMP_0_PIN
 */

I also believe you have your Port A upside down in your description

Looking in .platformio/packages/framework-arduino-avr/variants/sanguino/pins_arduino.h is

// ATMEL ATMEGA644/ATMEGA1284 / SANGUINO
//
//                        +---\/---+
//            (D 0) PB0  1|        |40  PA0 (AI 0 / D31)
//            (D 1) PB1  2|        |39  PA1 (AI 1 / D30)
//       INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
//        PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
//     SS PWM (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
//       MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
//       MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
//        SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
//                  RST  9|        |32  AREF
//                  VCC 10|        |31  GND
//                  GND 11|        |30  AVCC
//                XTAL2 12|        |29  PC7 (D 23)
//                XTAL1 13|        |28  PC6 (D 22)
//       RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
//       TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
//  INT0 RX1 (D 10) PD2 16|        |25  PC3 (D 19) TMS
//  INT1 TX1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
//       PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
//       PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
//       PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
//                        +--------+

PA0 is D31 (A0), PA7 is D24 (A7)

syriloak commented 10 months ago

Hi ellensp!

Thank you very much for your effort and sorry for wasting your time.

I'have tested this stuff in every possible way, and it still not working properly. Then I've realized that the HAL for AVR is based on this "wonderful" arduino thing. From this point it's simply doesn't worth my time and energy, and I don't want to waste anyone's time. This "duino" stuff is something that I'd like stay as far as humanly possible.

I wish you a wonderful and productive day!

github-actions[bot] commented 8 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.