Bueno de regreso con lo del VFD, ya he leido el datasheet y sobre el protocolo i80 que es el que utilizo para utilizar el VFD. A continuacion les dejo la libreria para inicializar el VFD, no se por que no funciona, trate de comentarla lo mas que pude, si alguien tiene una sugerencia de como debo de inicializarlo, o de como debo de escribir un byte/comando hacia el VFD se lo agradeceria.
/*LIBRERIA PARA CONTROLAR UN VFD DE LA MARCA NORITAKE MODELO CU16025-UW6J UTILIZANDO 8 BITS PARA ENVIAR DATOS, POR MEDIO DEL PUERTO E
Y USANDO LOS PINES C1 COMO "WR" (WRITE ENABLE) Y C2 COMO "RD" (READ ENABLE) EN EL PIC24FJ128GA010*/
#ifndef __VFD_AMS24
#define __VFD_AMS24
#define FCY 2000000UL //PARA UTILIZAR LAS FUNCIONES DE LOS RETARDOS
#include<libpic30.h> //LIBRERIA PARA LOS RETARDOS
//DEFINICION DE BITS DE CONTROL DEL VFD
#define WR PORTCbits.RC1 //WRITE ENABLE
#define RD PORTCbits.RC2 //READ ENABLE
#define RS PORTCbits.RC3 //RS SELECTS, DATA OR COMMAND
#define DATO PORTE // DATA/COMAND INPUT
void vfd_write_cmd(unsigned char command)
{
RD=0; //NO SE LEERA!!!!
RS=0; //SE ESCRIBIRA UN COMANDO
WR=1; //WR EN ALTO
WR=0; //WR PASA A BAJO
__delay_us(2); //PEQUEÑO RETARDO
WR=1; //WR ALTO
DATO=command; //SE MANDA EL COMANDO AL BUFFER
__delay_us(2);
WR=0; //WR DE NUEVO EN BAJO
}
void vfd_write_dato(unsigned char data)
{
RD=0; //NO SE LEERA!!!!
RS=1; //SE ESCRIBIRA UN COMANDO
WR=1; //WR EN ALTO
WR=0; //WR PASA A BAJO
__delay_us(2); //PEQUEÑO RETARDO
WR=1; //WR ALTO
DATO=data; //SE MANDA EL COMANDO AL BUFFER
__delay_us(2);
WR=0; //WR DE NUEVO EN BAJO
}
void vfd_init() //FUNCION PARA INICIALIZAR EL VFD
{
TRISCbits.TRISC1=0; //RC1 COMO SALIDA
TRISCbits.TRISC2=0; //RC2 COMO SALIDA
TRISCbits.TRISC3=0; //RC3 COMO SALIDA
TRISE=0; //TODO EL PUERTO E COMO SALIDAS
PORTE=0;
PORTCbits.RC1=0; //APAGADO DE LOS PINES
PORTCbits.RC2=0; //APAGADO DE LOS PINES
PORTCbits.RC3=0; //APAGADO DE LOS PINES
vfd_write_cmd(48); //FUNCTION SET
// WR DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
// 0 0 0 1 IF * * * * *= don´t care
// 0 0 0 1 1 0 0 0 0
vfd_write_cmd(48); //FUNCTION SET
// WR DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
// 0 0 0 1 IF * * * * *= don´t care
// 0 0 0 1 1 0 0 0 0
vfd_write_dato(0); //BRIGHTNESS SET
// WR DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
// 0 0 0 0 0 0 0 BR1 BR0
// 0 0 0 0 0 0 0 0 0
vfd_write_cmd(1); //COMANDO CLEAR DISPLAY
// WR DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
// 0 0 0 0 0 0 0 0 1
vfd_write_cmd(128); //SET THE ADDRESS COUNTER TO POINT DE DD RAM
// WR DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
// 0 1 0 0 0 0 0 0 0
vfd_write_cmd(7); //DISPLAY ON/OFF
// WR DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
// 0 0 0 0 0 0 D C B
// 0 0 0 0 0 0 1 1 1
vfd_write_cmd(6); //ENTRY MODE SET
// WR DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
// 0 0 0 0 0 0 1 I/D S
// 0 0 0 0 0 0 1 1 0
}
#endif
/*
BITS DE CONTROL DEL BYTE "DISPLAY ON/OFF"
D=1: Display on
D=0: Display off
The C bit turns the cursor on or off.
C=1: Cursor on
C=0: Cursor off
The B bit enables blinking of the character the cursor coincides with.
B=1: Blinking on
B=0: Blinking off */
/*
BITS DE CONTROL DEL BYTE "ENTRY MODE SET"
The I/D bit selects the way in which the contents of the address counter are modified after every access to DDRAM or CGRAM.
I/D=1: The address counter is increment.
I/D=0: The address counter is decrement.
The S bit enables display shifts instead of cursor shift, after each write or read to the DDRAM.
S=1: Display shift enabled.
S=0: Cursor shift enabled.
*/
/*
BITS DE CONTROL DEL BYTE "FUNCTION SET"
This command sets width of data bus line by itself, and sets screen brightness by following one byte data.
This instruction initializes the system, and must be the first instruction executed after power-on.
The IF bit selects between an 8-bit or a 4-bit bus width interface.
IF=1: 8-bit CPU interface using DB7 to DB0
IF=0: 4-bit CPU interface using DB7 to DB4
*/
/* BITS DE CONTROL DEL BYTE "BRIGHTNESS CONTROL"
One byte data (RS=1) which follows the "Function Set Command" is considered as brightness data. When a command (RS=0) is written after the "Function Set Command", the brightness
control function is not initiated. Screen brightness is as follows.
BR1 BR0 Brightness
-------- -------- -----------------------
0 0 100 % (Default)
0 1 75 %
1 0 50 %
1 1 25 %
*/