OLA PESSOAL ,AINDA NAO FUNCIONOU ,ESCREVI O CODIGO ,VEJA SE ESTA CORRETO
OBRIGADO
// Software I2C connections
sbit Soft_I2C_Scl at RC3_bit;
sbit Soft_I2C_Sda at RC4_bit;
sbit Soft_I2C_Scl_Direction at TRISC3_bit;
sbit Soft_I2C_Sda_Direction at TRISC4_bit;
// End Software I2C connections
// Lcd pinout settings
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
char alc_,comp_,RFG,A_;
unsigned reg,reg2_0,reg0_7,reg_7;
unsigned freq,f_,freq_d;
//char txt[11];
char txt[11];
char ch,str[1];
int mat [3][4];
void fmtx_write_reg (char adress, unsigned dado)
{
Soft_I2C_Start(); // Issue start signal
Soft_I2C_Write(62);
Soft_I2C_Write(adress);//2:0;
Soft_I2C_Write(dado);//7:0;
//Soft_I2C_Write(dt);//7;
Soft_I2C_Stop(); // Issue stop signal
Delay_ms(5); //tempo de uma gravação
}
void main() {
TRISB = 0;
PORTB = 0xFF;
TRISB = 0xff;
TRISc = 0;
//ANSEL = 0; // Configure AN pins as digital I/O
//ANSELH = 0;
//C1ON_bit = 0; // Disable comparators
//C2ON_bit = 0;
f_=0;
A_=0;
Soft_I2C_Init(); // Initialize Soft I2C communication
//fmtx_set_freq(180);
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off
freq=91;
f_=(freq*20); //00000111 00011100=1820 91mhz
//00000110 01000000=1600 80mhz
//reg0_7=0b01010100;
//reg2_0=0b00000111;
//reg_7 =0b00000000;
//alc_ =0b10000000;
//comp_ =0b11100000;
// RFG= 0b01000000;
//RFG= A_;
//fmtx_write_reg(0x02,RFG);
// fmtx_write_reg(0x14, alc_);
// fmtx_write_reg(0x15, comp_);
reg2_0=f_>>8;
reg0_7=f_>>0;
reg_7=f_<<7;
LongWordToStr(F_, txt);
lcd_out(1,1,txt);
fmtx_write_reg(0x01, reg2_0);
fmtx_write_reg(0x00, reg0_7);
fmtx_write_reg(0x02, reg_7);
//LongWordToStr(f_, txt);
}