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

Support of Atmega8 #363

Closed
xfmoulet opened this issue Nov 9, 2022 · 8 comments · Fixed by #384
Closed

Support of Atmega8 #363

xfmoulet opened this issue Nov 9, 2022 · 8 comments · Fixed by #384
Labels
mcu-support Support for a new Microcontroller

Comments

@xfmoulet
Copy link

xfmoulet commented Nov 9, 2022

Hi, I would like to use the Atmega8 chip, which do not seem to be supported by now.
I don't know enough of the avh-hal system to implement it myself (but I could try with some help)

@stappersg
Copy link
Contributor

stappersg commented Nov 9, 2022 via email

@Rahix
Copy link
Owner

Rahix commented Nov 17, 2022

@stappersg, #362 adds a board to arduino-hal, that's not what the issue poster needs to do. They need to add a new MCU to atmega-hal which works differently.

@xfmoulet, as a reference for adding a new MCU, maybe PR #306 is a better candidate. You need to mostly follow what happens there. You can open a draft PR once you got the bare basics working and need help with some more specific things (e.g. ADC, PWM, ...). Just let me know when you get stuck anywhere.

@Rahix Rahix added the mcu-support Support for a new Microcontroller label Nov 17, 2022
xfmoulet added a commit to xfmoulet/avr-hal that referenced this issue Nov 21, 2022
@xfmoulet
Copy link
Author

I have an issue (so closing this PR for the moment) : adps() method prescaler_2 does not exist, only bit definitions ...
I try to find a way to temporarily disable the ADC device for the moment (I guess the other possibility would be to enable is automated extraction in avr-device ?)

@Rutherther
Copy link
Contributor

I think I have done the needed patches in avr-device for this. See Rahix/avr-device#112
I've also tried to implement ATmega8 to avr-hal, see the relevant commit here: Rutherther@67fb8b1

There were some problems with that as the rest of the ATmega's are different to ATmega8 (EEPROM does not use erase mode, ADC does not have DIRD). I have added macros to avr-generic-hal specific to ATmega8 (in eeprom.rs and adc.rs), does that make sense? I suppose there are other microcontrollers that will work the same way so it could be useful in the future. What do you think, @Rahix? Do you have any better idea?

Also name of the register for wdt is different, as a hotfix I added cfg feature to avr-generic-hal wdt.rs. What is the correct way to handle this? Should I add parameters to the macro that will access the correct register? (wdtcsr for other megas, wdtcsr for ATmega8)

I have not yet tested anything except EEPROM, so I won't make a PR yet, but you can expect it in a week.

@Rutherther
Copy link
Contributor

Rutherther commented Dec 21, 2022

Another thing is that ATMega8 does not support watchtog at 4000 ms and 8000 ms timeouts, what would the correct way to handle that be? main...Rutherther:avr-hal:main#diff-6697f39027bdefb403a8c88673c635515ca9737eb92bf78393b97feffc9b6725R39

Also the rest of the other timeouts areno not exaclty the same either for ATmega8:
image
(instead of 125 ms it's 130 ms, and it gets worse the higher we go)

@Rahix Rahix linked a pull request Jan 5, 2023 that will close this issue
@Rahix
Copy link
Owner

Rahix commented Jan 5, 2023

As we now have two PRs for ATmega8 open here, #368 by @xfmoulet and #384 by @Rutherther, how shall we proceed? Should we just drop one or is there work to be merged from both?

@xfmoulet
Copy link
Author

xfmoulet commented Jan 5, 2023

I did not have enough time to pursue patching the generator, and I think @Rutherther went further than I did with its implementation, I can retire mine if you agree with it.

@Rahix
Copy link
Owner

Rahix commented Jan 5, 2023

Alright, let's go that route. Thanks anyway for initially starting the work on this topic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mcu-support Support for a new Microcontroller
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants