Skip to content
Snippets Groups Projects
Commit 964ea3af authored by Will Langford's avatar Will Langford
Browse files

Upload New File

parent 20c21de2
Branches
No related tags found
No related merge requests found
Pipeline #
//
// hello.blink
//
// 128a4u, blinking on PC1
//
#include <avr/io.h>
#include <util/delay.h>
#include <avr/pgmspace.h>
#define DELAY 500 // blink delay
#define LED PIN1_bm // LED bit mask
int main(void) {
// seems to go too fast
//OSC.PLLCTRL = OSC_PLLFAC4_bm | OSC_PLLFAC3_bm; // 2 MHz * 24 = 48 MHz
//OSC.CTRL = OSC_PLLEN_bm; // enable PLL
//while (!(OSC.STATUS & OSC_PLLRDY_bm)); // wait for PLL to be ready
//CCP = CCP_IOREG_gc; // enable protected register change
//CLK.CTRL = CLK_SCLKSEL_PLL_gc; // switch to PLL
//
// set up clock
//
OSC.CTRL = OSC_RC32MEN_bm; // enable 32MHz clock
while (!(OSC.STATUS & OSC_RC32MRDY_bm)); // wait for clock to be ready
CCP = CCP_IOREG_gc; // enable protected register change
CLK.CTRL = CLK_SCLKSEL_RC32M_gc; // switch to 32MHz clock
//
// set up port
//
PORTC.DIR = LED;
//
// main loop
//
while (1) {
PORTC.OUT = LED;
_delay_ms(DELAY);
PORTC.OUT = 0;
_delay_ms(DELAY);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment