LCD 2x16 MC68HC908GP32

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LCD 2x16 MC68HC908GP32

2,636 次查看
moriannair
Contributor I
Hello

I don't know if anyone can help me, I'm trying to implement a program for to show the temperature in a 2x16 LCD with GP32 and the truth I don´t know that is wrong with the program. If someone has a similar program what I can copy.

This is the code that I have so far.

Thank you very much for your help.
 
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC68HC908GP32.h> /* include peripheral declarations */
 
#define SALIDA PTA  /* Todos los ports B como salida */
#define Temp PTB_PTB0 /* entradas del sensor Temp-PTB0,Humedad-PTB1 */
#define Hume PTB_PTB1
#define RW PTC_PTC0  //Defino el puerto C0, C1, C2 como salida de control para
#define RS PTC_PTC1  //activar los BITs de la lcd
#define EN PTC_PTC2
 
char decimal1=0,entero=0,T=0;
char LCD[10]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
 
interrupt 16 void conversor (void) {
ADSCR_COCO=0;
SALIDA=ADR;
}
void timecontrol (void) {               //subrutina de retardo
long int R=0;
for (R=0;R<3000;R++){
}
}
 
void controllcd (){
RS=0;
EN=0;
EN=1;
EN=0;
timecontrol();
}
v
oid configuracion (void){
timecontrol();
SALIDA=0x01;            //limpiar pantalla
controllcd ();          //Llama Control de LCD
SALIDA=0x02;            //Envia a Inicio del LCD (Home)
controllcd ();          //Llama Control de LCD
SALIDA=0x06;            //Desplazamiento del Cursor
controllcd ();
SALIDA=0x0E;            //Envia display ON, cursor ON, blink OFF,
controllcd ();          //Llama Control de LCD
SALIDA=0x38;            // Habilita las dos líneas de la LCD
controllcd ();          //Llama Control de LCD
}

void Datos (void){
RS=1;
EN=0;
EN=1;
EN=0;
timecontrol();
}
 
void main (void){
  DDRA=0xFF;       //Configuracion de las salidas del puerto A LCD
  DDRB=0x00;       //Configuro el puerto B con 0x03. para entradas de los sensores
  DDRC=0X07;
  ADSCR=0x60;
  ADCLK=0x80;
  CONFIG1_COPD=1;
  EnableInterrupts;
  RW=0;
  RS=0;
  EN=0;
  timecontrol();
  configuracion();
  SALIDA=0x54;       //Letra T
  Datos ();
  SALIDA=0x45;       //Letra E
  Datos ();
  SALIDA=0x4D;       //Letra M
  Datos ();
  SALIDA=0x50;      //Letra P
  Datos ();
  SALIDA=0x20;      //Espacio
  Datos ();
  SALIDA=LCD[decimal1];  //Decimal 1
  Datos ();
  SALIDA=LCD[entero];   //Entero
  Datos ();
  SALIDA=0x20;      //Espacio
  Datos ();
  SALIDA=0xDF;      //Simbolo °
  Datos ();
  SALIDA=0x43;      //Letra C
  Datos ();
  for(;:smileywink:{
  T=ADR*100;
  entero=T/10;
  decimal1=T%10;
  }
}
 
 
Hola
No se si alguien me puede ayudar, estoy tratando de implementar un programa para visualisar la temperatura en una LCD de 2x16 con GP32 y la verdad no se que está mal en el programa.  Si alguien tiene un programa parecido me lo pueden copiar.
este es el código que tengo hasta el momento.
Muchas gracias por su ayuda.
标签 (1)
0 项奖励
回复
4 回复数

821 次查看
admin
Specialist II

PUEDO AYUDAR PERO NO MANEJO LENGUAJE C, YO PROGRAMO EN ASEMBLER

0 项奖励
回复

821 次查看
eckhard
Contributor V

Hello,

maybe this may help you : http://www.eckhard-gosch.de/en/articles.php?article_id=10

Its a C Project for a JK8 but the sofware will work on a GP32 if you change the pins accordind to your wiring.

Eckhard

0 项奖励
回复

821 次查看
bigmac
Specialist III
Hello,
 
For each temperature reading, you will need to convert the 8-bit binary value to a series of display characters to represent the temperature value.  Further, when each new reading is displayed, the position of the cursor would need to be adjusted so that the new reading will over-write the old reading.  Your code seems to be lacking some of these features.
 
In particular, your ISR code would appear inappropriate because you are loading Port A register, presumably for display purposes, with the raw ADC value.  Additionally, you do not seem to synchronise the display update (which should be done within the main loop) with the completion of the ADC reading, perhaps using a special flag for communication between the ISR and the main loop.
 
For this application, it may be simpler to use polling of the COCO flag within the main loop, rather than attempting to use the ADC interrupt.
 
Regards,
Mac
 
0 项奖励
回复

821 次查看
JimB
Contributor I
You don't say if you've managed to get anything on the display, but AN2940 looks like it could be helpful. I've often seen it written that the contrast setting for the display is a trap - you can get the code right, but still not see anything!
 
Jim
 
0 项奖励
回复