#include "mcc_generated_files/mcc.h"
#include <xc.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void putch(char txData)
{
EUSART1_Write(txData) ;
}
void EUSART_Write(const char *x)
{
__delay_ms (1);
while(*x)
{
if(EUSART1_is_tx_ready())
{
EUSART1_Write(*x++);
}
}
}
/*
Main application
*/
void main(void)
{
// Initialize the device
SYSTEM_Initialize();
__delay_ms (500);
// Timer Initialize and Start
TMR0_Initialize();
TMR0_StartTimer();
int i = 1;
char string_1[50] = "";
char string_2[50] = "";
// If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
// If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global and Peripheral Interrupts
// Use the following macros to:
// Enable the Global Interrupts
//INTERRUPT_GlobalInterruptEnable();
// Disable the Global Interrupts
//INTERRUPT_GlobalInterruptDisable();
// Enable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptEnable();
// Disable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptDisable();
while (1)
{
// Add your application code
i++;
strcpy(string_1, "\r\n\r\n\Count = ");
sprintf(string_2, "%d", i);
strcat(string_1 , string_2);
EUSART_Write(string_1);
PORTCbits.RC4 = 0;
PORTCbits.RC5 = 0;
if (TMR0_HasOverflowOccured())
{
EUSART_Write(" Timer Overflowed ");
TMR0_StopTimer();
PORTCbits.RC4 = 1;
PORTCbits.RC5 = 1;
__delay_ms (100);
TMR0_Initialize();
TMR0_StartTimer();
}
}
}
/**
End of File
}