792
/* * File: main.c * Author: Marwen Maghrebi * * Description: * This code demonstrates interrupt-driven ADC reading and UART communication on a PIC microcontroller. * It blinks LEDs, reads analog voltage from a potentiometer, and sends the voltage readings via UART. * Additionally, it handles an external button interrupt to trigger an LED blink and UART message. */ #include <xc.h> #include <stdint.h> #include <stdio.h> // Configuration bits #pragma config FOSC = HS // High-Speed Oscillator #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled) #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled) #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off) #pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) #define _XTAL_FREQ 20000000 // Define oscillator frequency for delay // Function Prototypes void init_config(void); void UART_send_string(const char* str); void __interrupt() ISR(void);