Hello.
I'm using this AVR IoT WG board that AVR Freaks gave away to some users.
I'm only trying to setup the AtMega4808 using MPLAB X IDE (v5.10) to try to program it to try to generate an 5KHz wave form.
My OS is Debian 9.6 and I'm using this User Manual and this Datasheet and I'm also using AVR-Tool Chain Docs to anything else that I might need. The version of AVR-Tool Chain MPLAB X IDE is using is 5.4.0.
The code I have is the following but it's not generating the required wave form with 5KHz frequency. The code is commented.
I need help to see what is wrong/missing, etc! I hope I provided all the information needed.
/* * File: LedBlink.c * Author: PsySc0rpi0n * * Created on 20 de Fevereiro de 2019, 21:35 */ #define F_CPU 20000000L #include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include <avr/io.h> #include <util/delay.h> /* * */ int main(int argc, char** argv) { //http://ww1.microchip.com/downloads/en/DeviceDoc/40002015A.pdf // Main Clock Configuration // page 84 CLKCTRL_MCLKCTRLA &= ~CLKCTRL_CLKSEL_OSC20M_gc; // Select 20MHz Internal Oscillator CLKCTRL_MCLKCTRLA |= CLKCTRL_CLKOUT_bp; // Output the clock to CLKOUT pin // page 85 CLKCTRL_MCLKCTRLB &= ~CLKCTRL_PEN_bp; // Disable Prescaler // page TCA0_SINGLE_CMP0 = 0x07cf; // TOP --> 5000Hz = (20e6)/(2*1(CMPn + 1)) <=> CMPn = 1999 //http://ww1.microchip.com/downloads/en/DeviceDoc/40002015A.pdf, page 190, 208, TCA0_SINGLE_CTRLB |= (1 << 0); // Wave Generation Mode --> FRQ TCA0_SINGLE_EVCTRL &= ~( (1 << 2) | (1 << 1) | (1 << 0)); //Incremental Ticks counting mode (Positive edge) - No events counting TCA0_SINGLE_CTRLB |= (1 << 4); //Compare channels enabled for ( ; ;){ } return (EXIT_SUCCESS); }