#define _XTAL_FREQ 8000000
// LCD
#define lcd_port PORTB
//LCD Registers addresses
#define LCD_EN 0x20 // EN=PB5
#define LCD_RS 0x10 // RS=PB4
// Includes
#include "htc.h"
#include "stdio.h"
#include "misc.h"
#include "LCD.h"
#include "ADC.h"
#include "DAC.h"
#include "test.h"
// Configuration
#pragma config IESO=OFF, OSC=INTIO67, BOREN=OFF, PWRT=OFF, WDT=OFF, PBADEN=OFF, LPT1OSC=OFF, MCLRE=ON
#pragma config DEBUG=OFF, STVREN=ON, LVP=OFF
//TEST Signals
#define check PORTBbits.RB6
int main()
{
OSCCON=0x70; // 00 for 31khz 70for8MHz 60for4MHz 40for1MHz
//OSCTUNE=OSCTUNE | 0x40;
//PLLEN=1;
ADCON0=0x01;
ADCON1=0x0A;
ADCON2=0x88;
TRISD=0;
PORTD=0;
TRISB=0;
PORTB=0;
TRISC=0;
PORTC=0;
TRISE=0;
PORTE=0;
//vth(250);
char str[10];
float v_analog, gm_value=0;
while(1)
{
start();
DAC_init();
lcd_init();
lcd_cmd(0x82);
lcd_str("MOSFET PARAMETERS");
rds_test();
gm(5);
/*
check=1;
DAC('B',2);
check=0;
DAC('B',1);
check=1;
__delay_us(10);
check=0;
DAC('B',2.5);
DAC('B',0);
*/
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
while(1)
{
v_analog=ADC(3);
lcd_cmd(0xDF);
lcd_str("Va=");
sprintf(str,"%5.3f",v_analog);
lcd_str(str);
ms(800);
}
ends();
}
}