elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Informática
| |-+  Electrónica
| | |-+  Inicializar LCD (Linux)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Inicializar LCD (Linux)  (Leído 3,015 veces)
¨°o.O (ßa¢Kg|姧) O.o°

Desconectado Desconectado

Mensajes: 32



Ver Perfil
Inicializar LCD (Linux)
« en: 14 Julio 2010, 13:26 pm »

Hola a todos,

Estoy usando un powertip pc1602f directamente conectado al puerto paralelo del pc utilizando el esquema este:
http://www.beyondlogic.org/parlcd/parlcd.htm

Todo bien lo energizo el lcd y me muestra la primera fila con bloques negros, hasta ahí bien pero ahora quiero mandar información por el puerto paralelo.

Si mirais la página vereis que hay un código fuente para mandar información al lcd, pero usa librerias de windows  :huh:

Dejo mi código intentado convertido en linux.

Código
  1. #include <stdio.h>  
  2. #include <string.h>  
  3. #include <unistd.h>  
  4. #include <fcntl.h>  
  5. #include <errno.h>  
  6. #include <termios.h>
  7. #include <stdlib.h>
  8. #include <unistd.h>
  9. #include <sys/io.h>
  10. #define PORTADDRESS 0x3f8
  11. #define DATA PORTADDRESS+0
  12. #define STATUS PORTADDRESS+1
  13. #define CONTROL PORTADDRESS+2
  14.  
  15. main(int argc, char **argv)
  16. {char string[] = {"Testing 1,2,3"};
  17.  
  18.    int count;
  19.    int len;
  20.  
  21.    char init[10];
  22.    init[0] = 0x0F; /* Init Display */
  23.    init[1] = 0x01; /* Clear Display */
  24.    init[2] = 0x38; /* Dual Line / 8 Bits */
  25.  
  26.    if (ioperm(PORTADDRESS,1,1))
  27.        fprintf(stderr, "No se puede acceder al: %x\n", PORTADDRESS), exit(1);
  28.  
  29.    outb(CONTROL, inb(CONTROL) & 0xDF);
  30.    outb(CONTROL, inb(CONTROL) & 0x08);
  31.  
  32.  
  33.    for (count = 0; count <= 2; count++)
  34.    {
  35.  
  36.        outb(DATA, init[count]);
  37.        outb(CONTROL,inb(CONTROL) | 0x01);
  38.        sleep(20);                                
  39.        outb(CONTROL,inb(CONTROL) & 0xFE);
  40.        sleep(20);                                  
  41.    }
  42.    outb(CONTROL, inb(CONTROL) & 0xF7);  
  43.  
  44.    len = strlen(string);
  45.  
  46.    for (count = 0; count < len; count++)
  47.    {
  48.        outb(DATA, string[count]);
  49.        outb(CONTROL,inb(CONTROL) | 0x01);
  50.        sleep(2);
  51.        outb(CONTROL,inb(CONTROL) & 0xFE);
  52.        sleep(2);
  53.    }
  54.  
  55. }


Compila perfectamente pero cuando lo quiero provar lo ejecuto como root y me arroja esto

Código
  1. root@ubuntu:/media/E80C-30D5/LCD/build# ./lcd
  2. Fallo de segmentación (`core' generado)
  3. root@ubuntu:/media/E80C-30D5/LCD/build#

Mirando el dmesg me encuentro con esto.

Código
  1. [ 3176.691837] lcd[3867] general protection ip:400cb4 sp:7fff887ad290 error:0 in lcd[400000+2000]
  2. root@ubuntu:/media/E80C-30D5/LCD/build#

Dejo el dmesg del ttyS*
Código
  1. root@ubuntu:/media/E80C-30D5/LCD/build# dmesg |grep ttyS
  2. [    2.335717] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
  3. [    2.335817] serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
  4. [    2.336100] 00:0b: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
  5. [    2.336207] 00:0c: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
  6. root@ubuntu:/media/E80C-30D5/LCD/build#





En línea

JCCC

Desconectado Desconectado

Mensajes: 17


Ver Perfil
Re: Inicializar LCD (Linux)
« Respuesta #1 en: 15 Julio 2010, 23:51 pm »

el programa es interesante...
yo estoy en pañales en linux.... XD...
haber si alguien te ayuda, depaso me enseñan a controlar perifericos en LINUX
 :P


En línea

Mr.Blue


Desconectado Desconectado

Mensajes: 441



Ver Perfil WWW
Re: Inicializar LCD (Linux)
« Respuesta #2 en: 15 Julio 2010, 23:58 pm »

si pedis que te muevan el post a programacion c++,  por ahi lo ve mas gente.

Manda mp a algun mod o global para avisarle, con el link del post.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Inicializar structuras en C
Programación C/C++
gonzaloi 2 4,983 Último mensaje 1 Abril 2011, 16:39 pm
por gonzaloi
Inicializar HDD
Hardware
Polydeuces 5 12,088 Último mensaje 9 Octubre 2012, 03:04 am
por _Slash_
[?] Inicializar vector y trabajar con el
ASM
MeCraniDOS 9 4,046 Último mensaje 5 Julio 2014, 01:05 am
por Eternal Idol
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines