Skip to content

Instantly share code, notes, and snippets.

@rescurib
Created March 18, 2019 05:12
Show Gist options
  • Save rescurib/32b439bf488bf4892c80f2ea26420b17 to your computer and use it in GitHub Desktop.
Save rescurib/32b439bf488bf4892c80f2ea26420b17 to your computer and use it in GitHub Desktop.
/*
* File: main.c
* Author: Rodolfo E. Escobar U.
*
* Created on 17 de marzo de 2019, 10:55 PM
*/
#include <xc.h>
#include <stdio.h>
#include <stdbool.h>
#include "lcd.h"
#define _XTAL_FREQ 48000000 // Fosc = 48MHz
void setup(void){
// --- Fuses
#pragma config PLLDIV = 2
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 1
#pragma config FOSC = HSPLL_HS
#pragma config PWRT = OFF
// ----------
}
void main(void) {
setup();
LCD lcd = { &PORTD, 5, 4, 0, 1, 2, 3 }; // RS,EN,D4,D5,D6,D7
LCD_Init(lcd);
//-- variables
float pi = 3.141592653;
char buff[11];
//---
while(1){
__delay_ms(100);
sprintf(buff,"%.4f",pi); //.Xf -> X: cifras significativas
LCD_Set_Cursor(0,0);
LCD_putrs("Pi = ");
LCD_Set_Cursor(0,6);
LCD_putrs(buff);
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment