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

Attiny85's PLOCK bit never sets (the PLL never locks) #474

Open
packocrayons opened this issue Jan 31, 2022 · 1 comment
Open

Attiny85's PLOCK bit never sets (the PLL never locks) #474

packocrayons opened this issue Jan 31, 2022 · 1 comment

Comments

@packocrayons
Copy link

packocrayons commented Jan 31, 2022

The following MWE reproduces the issue:

#include <avr/io.h>
#include <util/delay.h>

int main(){
        PLLCSR = (1 << PLLE);
        _delay_us(100);
        while (! (PLLCSR & (1 << PLOCK)));
        PLLCSR |= (1 << PCKE);
}

Running with simavr and avr-gdb (-ggdb -Og) and a breakpoint on line 8 (the PCKE line), never breaks. The emulator gets stuck on line 7 waiting for "hardware" to set the PLOCK bit to confirm that the PLL is locked

avr-gcc -mmcu=attiny85 -Wall -DF_CPU=8000000 -Og -ggdb -o main main.c

P.S. I would be happy to work on this issue, given a pointer on where to start to emulate the PLL

@gatk555
Copy link
Collaborator

gatk555 commented Feb 2, 2022

My guess is that the counter/timer code (avr_timer.*) is the natural home for that. The data sheet documents PLLCSR in the counter/timer section.

This link may be useful: other AVRs with PLL.

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