From 04a4bc4dea786e91cfd1a13f6ac04fe526dbf459 Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Tue, 9 Jul 2024 18:47:16 -0700 Subject: [PATCH] Updated to disable the main clock's pre-scaler. Allows it to run at full 20MHz --- main.c | 10 ++++++++++ nbproject/private/private.xml | 3 +++ 2 files changed, 13 insertions(+) diff --git a/main.c b/main.c index d3460fe..03044f8 100644 --- a/main.c +++ b/main.c @@ -26,6 +26,7 @@ #include "ADC.h" #include "TriacOut.h" #include "load.h" +#include /* Required header file */ #include #include @@ -35,8 +36,17 @@ void (*Delay_MicroSeconds)(double us) = _delay_us; //void (*Delay_MicroSeconds)(double us) = _delay_ms; +static void CLK_DisablePrescaler(void) +{ + //CCP = CCP_IOREG_gc; /* Write the needed signature to CCP*/ + ccp_write_io((void *) & (CLKCTRL.MCLKCTRLA), 0x00); //select internal 20MHz clock. + ccp_write_io((void *) & (CLKCTRL.MCLKCTRLB), 0x00); //Disable the pre-scaler. +} + + int main(int argc, char **argv) { + CLK_DisablePrescaler(); while(true){ for(int i = 0; i < GatePulsesQty; i++){ ZCD_Poll(); diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 63881df..420dcec 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -6,6 +6,9 @@ file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/main.c file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/load.c file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/load.h + file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/config.h + file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/RegEdit.c + file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/ADC.c