#define PFS154
#define F_CPU 500000
#define TARGET_VDD_MV 4000
#define TARGET_VDD 4.0
#include <pdk/device.h>
#include "auto_sysclock.h"
#include "startup.h"
#include "delay.h"
// Main program
void main() {
PAC &= ~((1<<6)|(1<<7));
PAPH &= ~((1<<6)|(1<<7));
PADIER &= ~((1<<6)|(1<<7));
EOSCR = 0xA0;
CLKMD = (uint8_t)(CLKMD_IHRC|CLKMD_ENABLE_IHRC|CLKMD_ENABLE_ILRC);
TM2B = 0x00;
TM2C = (uint8_t)(TM2C_CLK_EOSC | TM2C_OUT_PA3 | TM2C_MODE_PWM );
TM2S = 0x01;
TM2B = 0x7f;
PAC |= (1 << 4);
// Main processing loop
while (1) {
PA &= ~(1 << 4);
PA |= (1 << 4);
}
}
// Startup code - Setup/calibrate system clock
unsigned char STARTUP_FUNCTION(void) {
// Initialize the system clock (CLKMD register) with the IHRC, ILRC, or EOSC clock source and correct divider.
// The AUTO_INIT_SYSCLOCK() macro uses F_CPU (defined in the Makefile) to choose the IHRC or ILRC clock source and divider.
// Alternatively, replace this with the more specific PDK_SET_SYSCLOCK(...) macro from pdk/sysclock.h
AUTO_INIT_SYSCLOCK();
// Insert placeholder code to tell EasyPdkProg to calibrate the IHRC or ILRC internal oscillator.
// The AUTO_CALIBRATE_SYSCLOCK(...) macro uses F_CPU (defined in the Makefile) to choose the IHRC or ILRC oscillator.
// Alternatively, replace this with the more specific EASY_PDK_CALIBRATE_IHRC(...) or EASY_PDK_CALIBRATE_ILRC(...) macro from easy-pdk/calibrate.h
AUTO_CALIBRATE_SYSCLOCK(TARGET_VDD_MV);
return 0; // Return 0 to inform SDCC to continue with normal initialization.
}