Skip to content

Refactoring analogWrite() to test for register, not cpu, definitions. [imported] #307

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

Closed
cmaglie opened this issue Nov 15, 2012 · 0 comments

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 307 moved from a Google Code project.
Added by 2010-07-28T21:54:20.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).

Original labels: Type-Enhancement, Priority-Medium, Component-Core, Milestone-0022

Original description

What change would like to see?

I have rewritten analogWrite and fixed an omission.

Why?

I have been doing a lot of work porting Arduino to other Atmega boards with other cpus. The cpu list includes 2560, 1281, 128, 644 and others. The timer portion of the code is the hardest part to port. There were a lot of cpu specific #ifdefs. Instead of using cpu #ifdefs, a better way of #ifdef the control port which is properly defined in the appropriate iomxxx.h file. This allows the code to work without having to make any changes when the code is ported to a new CPU.

Additionally while doing this I discovered that timer TIMER5C which controls the PWM on mega pin 44 (Port L bit 5) was omitted and therefore the PWM function on this pin did not work.

Would this cause any incompatibilities with previous versions? If so, how
can these be mitigated?

No issues at all

I used a switch statement instead of if else

on the atmega328 it takes 14 more bytes

on the atmega1280 it takes 40 more bytes

the speed should be faster

@cmaglie cmaglie closed this as completed Nov 15, 2012
tbowmo pushed a commit to tbowmo/Arduino that referenced this issue Jul 14, 2016
Created set(bool) to avoid typecasting on samd arch
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

1 participant