Updated to disable the main clock's pre-scaler. Allows it to run at full 20MHz

This commit is contained in:
jakeg00dwin 2024-07-09 18:47:16 -07:00
parent eba8344e36
commit 04a4bc4dea
2 changed files with 13 additions and 0 deletions

10
main.c
View File

@ -26,6 +26,7 @@
#include "ADC.h" #include "ADC.h"
#include "TriacOut.h" #include "TriacOut.h"
#include "load.h" #include "load.h"
#include <avr/cpufunc.h> /* Required header file */
#include <avr/io.h> #include <avr/io.h>
#include <util/delay.h> #include <util/delay.h>
@ -35,8 +36,17 @@
void (*Delay_MicroSeconds)(double us) = _delay_us; void (*Delay_MicroSeconds)(double us) = _delay_us;
//void (*Delay_MicroSeconds)(double us) = _delay_ms; //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) int main(int argc, char **argv)
{ {
CLK_DisablePrescaler();
while(true){ while(true){
for(int i = 0; i < GatePulsesQty; i++){ for(int i = 0; i < GatePulsesQty; i++){
ZCD_Poll(); ZCD_Poll();

View File

@ -6,6 +6,9 @@
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/main.c</file> <file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/main.c</file>
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/load.c</file> <file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/load.c</file>
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/load.h</file> <file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/load.h</file>
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/config.h</file>
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/RegEdit.c</file>
<file>file:/home/ronin/Documents/projects/freelance/laith_naaman/fg004a.X/ADC.c</file>
</group> </group>
</open-files> </open-files>
</project-private> </project-private>