我使用直接連接到使用該方案的PC並行端口pc1602f PowerTip: http://www.beyondlogic.org/parlcd/parlcd.htm編程232到LCD(Linux)的
所有以及激勵LCD,顯示我有黑色塊的前排,直到那時好,但現在我想通過並行端口發送信息。
如果你看一下頁面,你會看到,有將信息發送到LCD的來源,但使用Windows庫:呵呵:
我離開我的代碼試圖成爲Linux操作系統。
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
#define PORTADDRESS 0x3f8
#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2
main(int argc, char **argv)
{char string[] = {"Testing 1,2,3"};
int count;
int len;
char init[10];
init[0] = 0x0F; /* Init Display */
init[1] = 0x01; /* Clear Display */
init[2] = 0x38; /* Dual Line/8 Bits */
if (ioperm(PORTADDRESS,1,1))
fprintf(stderr, "No se puede acceder al: %x\n", PORTADDRESS), exit(1);
outb(CONTROL, inb(CONTROL) & 0xDF);
outb(CONTROL, inb(CONTROL) & 0x08);
for (count = 0; count <= 2; count++)
{
outb(DATA, init[count]);
outb(CONTROL,inb(CONTROL) | 0x01);
sleep(20);
outb(CONTROL,inb(CONTROL) & 0xFE);
sleep(20);
}
outb(CONTROL, inb(CONTROL) & 0xF7);
len = strlen(string);
for (count = 0; count < len; count++)
{
outb(DATA, string[count]);
outb(CONTROL,inb(CONTROL) | 0x01);
sleep(2);
outb(CONTROL,inb(CONTROL) & 0xFE);
sleep(2);
}
}
完全編譯,但是當我想嘗試,因爲根目錄並運行它拋出我
media/E80C-30D5/LCD/build #./lcd
Segmentation fault (`core 'generated)
[email protected]: /media/E80C-30D5/LCD/build #
看着dmesg的我發現這一點。
[3176.691837] lcd [3867] general protection ip: 400cb4 sp: 7fff887ad290 error: 0 in lcd [+2000 400 000][email protected]:/media/E80C-30D5/LCD/build #
我把TTYS的dmesg的日誌*
root @ ubuntu:/media/E80C-30D5/LCD/build # dmesg | grep ttyS
[2.335717] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[2.335817] serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
[2.336100] 00:0 b: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
[2.336207] 00:0 c: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
root @ ubuntu:/media/E80C-30D5/LCD/build #
不要讓它跑,你能幫助我嗎?
這一口井必須設計一個模塊才能使其工作或有可能完全激活端口的不同位? – Backglass 2010-07-14 13:33:44
也許有人已經寫了一個驅動程序。看看http://lcd-linux.sourceforge.net/是否有用。另外,我的建議是否解決了您的問題? – Artelius 2010-07-14 13:50:59