Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arduino framework does'nt work on ATmega128 #198

Closed
GHOST-mHBr opened this issue Apr 14, 2023 · 2 comments
Closed

arduino framework does'nt work on ATmega128 #198

GHOST-mHBr opened this issue Apr 14, 2023 · 2 comments

Comments

@GHOST-mHBr
Copy link

GHOST-mHBr commented Apr 14, 2023

I have an ATmega128 micro-controller and i am trying to just program it!
I successfully program it with MegaCore boot loader (because the LED is blinking twice every second) using Arduino as isp programmer. then when i upload the following code on it (again with arduino as isp), the led does not blink

void setup() {
  pinMode(15,OUTPUT);
}

void loop() {
  digitalWrite(15,1);
  delay(200);
  digitalWrite(15,0);
  delay(200);
}

but when i program the I/O registers myself, the led works correctly. the following code works:

void setup() {
  DDRB = PORTB|(1<<PB5);
}

void loop() {
  PORTB |= (1<<PB5);
  delay(200);
  PORTB &= ~(1<<PB5);
  delay(200);
}

i'm not sure where is the problem

also there is another problem with programming the micro-controller, after uploading the boot loader (MegaCore), i can't program it by USB to serial module. AVRdude's logs say that the response code is wrong:

         Using Port                    : /dev/ttyUSB2
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude ser_recv() OS error: unable to read: Resource temporarily unavailable
avrdude stk500_recv() error: programmer is not responding
avrdude stk500_getsync() warning: attempt 1 of 10: not in sync: resp=0x00
avrdude stk500_getsync() error: cannot communicate with device: resp=0xfc
avrdude main() error: unable to open programmer arduino on port /dev/ttyUSB2

this is my usb to serial module(its rx tx leds blink when i try program the mcu):
https://www.aliexpress.com/item/2038553639.html

@GHOST-mHBr GHOST-mHBr changed the title pinMode does'nt work on ATmega128 arduino framework does'nt work on ATmega128 Apr 14, 2023
@GHOST-mHBr
Copy link
Author

this is the schematic
image

@MCUdude
Copy link
Owner

MCUdude commented Aug 30, 2023

It is because you're using the wrong Arduino pin when trying to toggle the LED. You're using 15 instead of 13. 15 is the physical pin of that particular package.

This will work:

void setup() {
  pinMode(13,OUTPUT);
}

void loop() {
  digitalWrite(13,1);
  delay(200);
  digitalWrite(13,0);
  delay(200);
}

But this is what I'd prefer:

void setup() {
  pinMode(PIN_PB5, OUTPUT);
}

void loop() {
  digitalWrite(PIN_PB5, 1);
  delay(200);
  digitalWrite(PIN_PB5, 0);
  delay(200);
}

@MCUdude MCUdude closed this as completed Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants