打印

跪求tm4c驱动12864的相关问题解答

[复制链接]
1721|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
sayato|  楼主 | 2014-10-31 11:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1,怎么读数据,我要读出这个端口的数据方便下次再写的时候把这个数据与下一个数据或了之后再送进去,
2,我得这个读程序对不对,unsigned char read(void)
{
    unsigned char byReturnValue ;
        checkBusy();
        GPIOPinWrite(GPIO_PORTB_BASE,0Xff,0x00);
    RS=1 ;
    RW=1 ;
    LCDE=0;
    LCDE=1 ;
    byReturnValue=GPIOPinRead(GPIO_PORTB_BASE,0Xff);//HWREG(GPIO_PORTB_BASE + GPIO_O_DATA );//
    LCDE=0 ;

    return byReturnValue ;
}


3,我要读出cgram里面的数据是我上面的那样操作吗, 或者是其他的什么操作吗,  
4,如果你是tm4c系列的玩家,若能帮我弄出一个随意画点的程序 电话费充值卡50元,绝不食言(必须能运行我用的是tm4c1233e6pm,用的液晶屏是12864带字库用st7920驱动的)
5,下面是我目前在调试的程序比较乱 如果不想看,就算了
#include"stdio.h"
#include<stdint.h>
#include<stdbool.h>
#include "inc/lm4f120e5qr.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/pwm.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h"
#include "inc/hw_gpio.h"

#define RS    HWREGBITW((GPIO_PORTA_BASE + GPIO_O_DATA+(GPIO_PIN_5<<2)), 5)
#define RW    HWREGBITW((GPIO_PORTA_BASE + GPIO_O_DATA+(GPIO_PIN_6<<2)), 6)
#define LCDE  HWREGBITW((GPIO_PORTA_BASE + GPIO_O_DATA+(GPIO_PIN_7<<2)), 7)

#define  BASIC_SET   0x30             //基本指令集0x30
#define  EXTEND_SET  0x34            //扩展指令集 0x34
#define  DRAW_ON     0x36           //绘图显示开 0x36
#define  DRAW_OFF    0x34          //绘图显示关0x34

#define Disp_on                0x0c        //显示开命令
#define Clr_scr                0x01        //清屏命令




void delayMs(uint16_t a)  //延时 a * 1ms
{
        uint16_t i, j;
    for(i = a; i > 0; i--)
        for(j = 100; j > 0; j--);
}

void delayUs(uint16_t a)  //延时 a * 1us
{
        uint16_t i;
    for(i = a; i > 0; i--);
}

void checkBusy(void)                //检测LCD是否处于忙状态, 若忙返回1, 空闲返回0
{
         RS = 0; //GPIOPinWrite(GPIO_PORTC_BASE,GPIO_PIN_7,0x00);
         RW = 1; //GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_3,0xFF);
         LCDE = 1; //GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_2,0xFF);

         delayMs(3);
         LCDE = 0; //GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_2,0x00);
}
void writeCmd(uint8_t cmd)        //写命令
{
        checkBusy();
         RS = 0; //GPIOPinWrite(GPIO_PORTC_BASE,GPIO_PIN_7,0x00);
         RW = 0; // GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_3,0x00);

        GPIOPinWrite(GPIO_PORTB_BASE,0xff,cmd);        //    LCD_DATA = cmd;

        LCDE = 1; //GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_2,0xFF);
        delayMs(3);
        LCDE = 0; //GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_2,0x00);

}
void writeData(uint8_t dat)        //写数据
{
        checkBusy();
          RS = 1; // GPIOPinWrite(GPIO_PORTC_BASE,GPIO_PIN_7,0xff);        //
          RW = 0; // GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_3,0x00);        //

        GPIOPinWrite(GPIO_PORTB_BASE,0xff,dat);        //     LCD_DATA = dat;

        LCDE = 1; //  GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_2,0xFF);
    delayMs(3);
    LCDE = 0; // GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_2,0x00);
}



void LCD_Init(void)
{
        //
    // Enable Peripheral Clocks
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
         //
         // Enable port PC7/PC6 for GPIOOutput
         //
        GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
    //
        // Enable port PB0~PB7 for GPIOInput
        //
    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, 0xff);

        GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_2,GPIO_PIN_2);                //PSB = 1;并口方式
}


void GUI_Clear(void)
{
        writeCmd(0X01);//清屏
     delayMs(100);
}
void setPosition(uint8_t x, uint8_t y)        //设置写数据坐标
{  uint8_t p;
    switch(x%4)
    {
        case 0: p = 0x80; break; //第一行        开始地址
        case 1: p = 0x90; break; //第二行
        case 2: p = 0x88; break; //第三行
        case 3: p = 0x98; break; //第四行
    }
    p += y;
    writeCmd(p);
}
void GUI_DispStringAtBar(char * str,uint8_t x, uint8_t y)
{
        uint8_t i= 0;
        setPosition(x,y);
        while(str[i] != '\0')
        {
                writeData(str[i++]);
        }
}
void DispMenuTopInit(void)//待机界面
{
        GUI_Clear();

    GUI_DispStringAtBar("为什么不行啊fuck",1,1);  // 内容
    GUI_DispStringAtBar("给我次机会",3,2);

}


//------------------清整个GDRAM空间----------------------------
void clrgdram()
{
          uint8_t i,j;
          writeCmd(0x34);//打开拓展指令集,绘图指令关
          for(j=0;j<8;j++)    //清除第一行
          {
            for(i=0;i<32;i++)
            {
                    writeCmd(0x80+i);//行
             writeCmd(0x80+j);//列
             writeData(0x00);//写高八位数据
              writeData(0x00);//写低八位数据
            }
          }

          for(j=0;j<8;j++)    //清除第二行
          {
            for(i=0;i<32;i++)
            {
                    writeCmd(0x80+i);
             writeCmd(0x88+j);
            writeData(0x00);
           writeData(0x00);
            }
           }
          writeCmd(0x30);//打开基本指令集
}
unsigned char read(void)
{
    unsigned char byReturnValue ;
        checkBusy();
        GPIOPinWrite(GPIO_PORTB_BASE,0Xff,0x00);
    RS=1 ;
    RW=1 ;
    LCDE=0;
    LCDE=1 ;
    byReturnValue=GPIOPinRead(GPIO_PORTB_BASE,0Xff);//HWREG(GPIO_PORTB_BASE + GPIO_O_DATA );//
    LCDE=0 ;

    return byReturnValue ;
}

void DrawPoint(unsigned char x,unsigned char y)
{
    unsigned char x_byte, x_bit;        //在横坐标的哪一个字节,哪一个位
    unsigned char y_byte, y_bit;
unsigned char tmph, tmpl;


    x_byte = x/16;                    //16位为一个地址,如0x80
    x_bit = x%16;                     //算出它在哪一个位

    y_byte = y /32;                     //0:上半屏 1:下半屏
    y_bit = y % 32;                     //y_bit确定它是在第几行

    writeCmd(0x34);                    //扩展指令集,同时绘图显示关闭

    writeCmd(0x80 + y_bit);                       //先写垂直地址
    writeCmd(0x80 + x_byte + 8 * y_byte);        //水平坐标
                                                 //下半屏的水平坐标起始地址为0x88

                                            //(+8*y_byte)就是用来确定在上半屏还是下半屏
    read();
tmph=read();
tmpl=read();

writeCmd(0x80 + y_bit);                       //先写垂直地址
    writeCmd(0x80 + x_byte + 8 * y_byte);



    if (x_bit < 8)                               //如果x_bit位数小于8
    {
            writeData(tmph|(0x01 << (7 - x_bit)));     //写高字节。因为坐标是从左向右的
                                                 //而GDRAM高位在左,底位在右
        writeData(tmpl);                    //低字节全部填0
    }
    else
    {
            writeData(tmph);                    //高字节全部填0
        writeData(tmpl|(0x01 << (15 - x_bit)));
    }

    writeCmd(DRAW_ON);                     //打开绘图显示
    writeCmd(BASIC_SET);                   //回到基本指令集,毕竟ST7920是以字符为主的

}


void main(void)
        {
        SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |                        // 设置外部时钟 80M
                                                                SYSCTL_XTAL_16MHZ);



   // wdogInit();
    LCD_Init();
    writeCmd(0X30);         //基本指令, 扩充指令为34H
    delayMs(30);
    writeCmd(0X0C);                 //显示开, 关光标
    delayMs(30);

    DispMenuTopInit();
    delayMs(50000);
    GUI_Clear();
    clrgdram();
    DrawPoint(127,63);
    delayMs(500);

    DrawPoint(127,62);
    delayMs(500);
     DrawPoint(126,62);

     delayMs(500);
      DrawPoint(126,61);


}
  其实我目前 主要想实现的功能就是把主函数里面调用的四个画点程序,  实现画4个点的功能,但是现在只能画出其中的三个点,有一个点被覆盖了,

相关帖子

沙发
dirtwillfly| | 2014-10-31 23:13 | 只看该作者
若是代码外包,建议去 创业|外包|承接板块问问

使用特权

评论回复
板凳
sayato|  楼主 | 2014-11-1 00:17 | 只看该作者
dirtwillfly 发表于 2014-10-31 23:13
若是代码外包,建议去 创业|外包|承接板块问问

什么叫代码外包

使用特权

评论回复
地板
sayato|  楼主 | 2014-11-1 00:18 | 只看该作者
这个 驱动问题 我已经解决了  上面说的话  就不算了 请谅解, 顺便说下具体的解决方法见另外一个帖子中有解释

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

12

主题

35

帖子

0

粉丝