Pienso que el siguiente código:
Habría de mostrar en el display "1234567890", pero sin embargo lo que hace es mostrar uno o más símbolo raros y a partir de ahí sólo muestra "3"s, quizás está leyendo algo distinto a lo que hay en dataString, ¿pero si es así por qué lo estaría leyendo? Y si no es eso ¿alguien ve donde puede estar el problema?
Gracias.
PD: Arreglado lo de los símbolos raros que era culpa de un cable cruzado, ahora muestra sólo 3s.
Código:
#include <stdio.h>
#include <P18CXXX.h>
#include <delays.h>
#include <timers.h>
#pragma code page // This code make sure the program starts from 0x0004, not from 0x0000
#pragma config WDT = OFF
#pragma config OSC=INTIO67
#define RS PORTEbits.RE1
#define dirRS TRISEbits.TRISE1
#define RW PORTBbits.RB1
#define dirRW TRISBbits.TRISB1
#define E PORTEbits.RE2
#define dirE TRISEbits.TRISE2
#define DATALCD PORTD
#define dirDATA TRISD
#define LCDBusy PORTDbits.RD7
void LCDdata (unsigned char);
void busylcd(void);
void LCDinit (void);
void LCDDelay( void );
void lcdcmd(unsigned char);
void stringtoLCD(unsigned char *m);
unsigned char dataString[10]="1234567890";
void main (void) // main function
{
TRISD = 0;
PORTD = 0;
TRISB = 0; // Port,pin direction configuration
PORTB = 0;
TRISC = 0;
PORTC = 0;
TRISCbits.TRISC7 = 1; // make sure this pin is input
ADCON1=255;
dirRS = 0;
LCDinit();
while (1) // this is how to make a never ending loop.
{
lcdcmd(0x1);
lcdcmd(0x2);
stringtoLCD(dataString);
}
}
//////////////////////////////////////////////////////////////////////////////////////
//LCD finctions------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////
void LCDdata (unsigned char value)
{
busylcd();
TRISD = 0;
DATALCD = value;
RS=1;
RW=0;
E=1;
LCDDelay();
E=0;
}
//--------------------------------------------------------------------------------------
void LCDinit(void)
{
TRISE=0;
lcdcmd(0x28); //set 4-bit mode and 2 lines
lcdcmd(0x10); //cursor move & shift left
lcdcmd(0x06); //entry mode = increment
lcdcmd(0x0d); //display on - cursor blink on
lcdcmd(0x01); //clear display
}
//-------------------------------------------------------------------------------------
void busylcd(void)
{
RS=0;
RW=1;
TRISD=255;
E=0;
LCDDelay();
E=1;
while(LCDBusy==1){
E=0;
LCDDelay();
E=1;
}
}
//-------------------------------------------------------------------------------------
void lcdcmd(unsigned char temp)
{
busylcd();
RS=0;
RW=0;
TRISD=0;
DATALCD=temp;
E=1;
LCDDelay();
E=0;
}
//--------------------------------------------------------------------------------------
void LCDDelay(void)
{
int i=0;
for (i=0;i<250;i++);
}
//---------------------------------------------------------------------------------------
void stringtoLCD(unsigned char *m)
{
unsigned char i;
i = 0;
while(i<10)
{
LCDdata(m[i]);
i++;
}
}
Habría de mostrar en el display "1234567890", pero sin embargo lo que hace es mostrar uno o más símbolo raros y a partir de ahí sólo muestra "3"s, quizás está leyendo algo distinto a lo que hay en dataString, ¿pero si es así por qué lo estaría leyendo? Y si no es eso ¿alguien ve donde puede estar el problema?
Gracias.
PD: Arreglado lo de los símbolos raros que era culpa de un cable cruzado, ahora muestra sólo 3s.
Última edición: