-
Notifications
You must be signed in to change notification settings - Fork 88
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
Counter TCNT3 of Timer3 is not defined #57
Comments
ADT0 - Auto-monitoring underflow threshold register pair ADT1 - Auto-monitoring overflow threshold register pair OCR3C - TC3 output compare register C ( defined, but not with _SFR_MEM16 ) DTR3 - TC3 dead time register DTR3 - TC3 dead time register low and high defined as wrong. Better definiton is: OCR3B - TC3 output compare register B ( defined, but not with _SFR_MEM16 ) OCR3A - TC3 output compare register A ( defined, but not with _SFR_MEM16 ) ICR3 - TC3 capture register DTR1 - TC1 dead time register DTR1 register is present in LGT8F328D too, so file |
Now it finally makes sense! This was driving me crazy, that I couldn't count beyond 255 in CTC mode using OCR3A as TOP. It is defined as a char currently. |
I found an issue. Weird but true. |
@LaZsolt - while reading documentation of Timer3 I saw that writing/reading a register may require specific order. E.g. "If write to 16-bit TCNT3, must write TCNT3H firstly. If read 16-bit TCNT3, must read TCNT3L first." Perhaps that's linked to your issue? Something else - Just in case you ever want to support analogWrite for PWM using Timer 3: |
@maxint-rd |
@LaZsolt - thank you for the swift reply. Good to know how to deal with 16-bit registers in an interrupt. I already fixed my copy of the .h file after your comment in another issue's thread. Thanks. Although it did get me to compile my code and have Timer3 running, at first the pin output wouldn't budge. Only after reading somewhere that OC3B was actually on PF2 instead of PD2, I found out I had to first disable PD2 and set PF2 as output to get my fast PWM output to work on pin 2. So I have it working now! (hooray). |
I'm glad I was able to help. |
Just faced another "quirk". |
I think it's not an error, but in the databook wasn't mentioned this kind of behaviour. In my undertanding the reason is maybe that the WGM bits 2 and 3 are not in the same register than bits 0 and 1. Between writing TCCRnA and TCCRnB maybe there a short time when WGM bits sets the fast PWM 8-bit mode which means the upper bytes of OCRnx registers will be cleared. |
Still, the manual writes something: |
Oh wow! I didn't see that! By the way, I noticed 2 differences between lgt328p and atmega328p timers:
I'm making a tool to configure and visualise timers so I guess I'll put that to the test soon (I want it to match reality after all hehe) |
The quoted text from "ATmega328_P AVR MCU with picoPower Technology Data Sheet" |
This issue can be closed and still serve as a reference for others later. |
Hello to all friends I'm having trouble reading tcnt3 on the atmega64 micro and it's not giving me the correct value |
You probably have the timer configured so that the top value is 255. |
Thanks mate, I'll check it out |
The core has the low and high bytes declared, but not the
16 bit uint
, which e.g. the Timer1 counterpart has (TCNT1)Defining it as
#define TCNT3 _SFR_MEM16(0x94)
works fine for me. Anything I'm missing?The text was updated successfully, but these errors were encountered: