lcd的8位数据线并不是接430的同一个Px口上

[复制链接]
 楼主| wyjie 发表于 2017-8-27 18:24 | 显示全部楼层 |阅读模式
我在使用MSP430F169的做一个OCM240128的lcd显示的时候,发现lcd的8位数据线并不是接430的同一个Px口上
spark周 发表于 2017-8-27 18:26 | 显示全部楼层
怎么了这个
shimx 发表于 2017-8-27 18:27 | 显示全部楼层
这样在写程序的时候非常麻烦
 楼主| wyjie 发表于 2017-8-27 18:29 | 显示全部楼层
是啊,能不能有什么方法把不在同一Px口上的8个管教宏定义成一个data
spark周 发表于 2017-8-27 18:44 | 显示全部楼层
写程序时候能直接对data进行操作?
dengdc 发表于 2017-8-27 18:46 | 显示全部楼层
你在做硬件设计的时候就可以考虑到,如果没接在一个Px上,那么就只有单个操作
heweibig 发表于 2017-8-27 18:49 | 显示全部楼层

你也可以把不同的口,定义在一个结构体里
 楼主| wyjie 发表于 2017-8-27 18:51 | 显示全部楼层

的确是在硬件设计的时候没经验,当时没想这么多,写程序的时候才发现这个问题,也考虑用结构体来解决,但结构体变量能跟普通变量之间直接赋值吗?还是有点糊!
spark周 发表于 2017-8-27 18:52 | 显示全部楼层
定义一个宏实现!
shimx 发表于 2017-8-27 18:53 | 显示全部楼层

我就是那么应用的,编写一个参数传递的子函数,运算赋值过去即可
yszong 发表于 2017-8-27 18:55 | 显示全部楼层
什么样的捷径,能不能具体点?
 楼主| wyjie 发表于 2017-8-27 18:56 | 显示全部楼层



我是这么写的,不知道有没有问题!望请指教!
struct byte
{
  unsigned char b0:1;
  unsigned char b1:1;
  unsigned char b2:1;
  unsigned char b3:1;
  unsigned char b4:1;
  unsigned char b5:1;
  unsigned char b6:1;
  unsigned char b7:1;
};

union bits
{
  unsigned char c;
  struct byte bit;
};

union bits b;
unsigned char ch;

430中的管教P3.1 P3.0 P2.7 P2.6 P2.5 P2.4 P2.3 P2.2要怎么和位段中的b.bit.b0...每位对上,直接赋值?怎么写啊?谢谢!
yszong 发表于 2017-8-27 18:58 | 显示全部楼层
我做过,用STM32的A、D、E三种口不挨着做数据和控制端口,晚上贴源代码给你看看,好像好久以前了
jiahy 发表于 2017-8-27 19:00 | 显示全部楼层
struct flag_inf{
  
               unsigned sleep:1;
               unsigned keycode:1;
               unsigned disp:1;
               unsigned Timer:1;

              }flag;
要用就flag.disp
lizye 发表于 2017-8-27 19:01 | 显示全部楼层
#define  LCD_CS10  GPIO_ResetBits(GPIOA, GPIO_Pin_7)
#define  LCD_CS11  GPIO_SetBits(GPIOA, GPIO_Pin_7)

#define  LCD_CS20   GPIO_ResetBits(GPIOA, GPIO_Pin_6)
#define  LCD_CS21  GPIO_SetBits(GPIOA, GPIO_Pin_6)

#define  LCD_DI0  GPIO_ResetBits(GPIOE, GPIO_Pin_14)
#define  LCD_DI1  GPIO_SetBits(GPIOE, GPIO_Pin_14)

#define  LCD_RW0  GPIO_ResetBits(GPIOE, GPIO_Pin_13)
#define  LCD_RW1   GPIO_SetBits(GPIOE, GPIO_Pin_13)

#define  LCD_E0   GPIO_ResetBits(GPIOE, GPIO_Pin_12)
#define  LCD_E1  GPIO_SetBits(GPIOE, GPIO_Pin_12)

#define  LCD_RST0  GPIO_ResetBits(GPIOA, GPIO_Pin_5)
#define  LCD_RST1  GPIO_SetBits(GPIOA, GPIO_Pin_5)

#define  H245_0  GPIO_ResetBits(GPIOC, GPIO_Pin_4)
#define  H245_1  GPIO_SetBits(GPIOC, GPIO_Pin_4)
lizye 发表于 2017-8-27 19:03 | 显示全部楼层
extern unsigned char data0[8];
extern unsigned char data1[8];
extern unsigned char data2[8];
extern unsigned char data3[8];
extern unsigned char data4[8];
extern unsigned char data5[8];
extern unsigned char data6[8];
extern unsigned char data7[8];
extern unsigned char data8[8];
extern unsigned char data9[8];
lizye 发表于 2017-8-27 19:04 | 显示全部楼层
//#define LCD_PORT             GPIOD
#define LCD_DISP_ON     0x3F
#define LCD_DISP_OFF    0x3E
#define LCD_DISP_ROW    0xC0
#define LCD_DISP_PAGE   0xB8
#define LCD_DISP_Y      0x40
lizye 发表于 2017-8-27 19:05 | 显示全部楼层
void DATA(u8 x)
{
        if(x&0x01)
        GPIO_SetBits(GPIOE, GPIO_Pin_11);         
        else
    GPIO_ResetBits(GPIOE, GPIO_Pin_11);

        if(x&0x02)
        GPIO_SetBits(GPIOE, GPIO_Pin_10);
        else
    GPIO_ResetBits(GPIOE, GPIO_Pin_10);

         if(x&0x04)
        GPIO_SetBits(GPIOE, GPIO_Pin_9);
        else
    GPIO_ResetBits(GPIOE, GPIO_Pin_9);

        if(x&0x08)
        GPIO_SetBits(GPIOE, GPIO_Pin_8);
        else
    GPIO_ResetBits(GPIOE, GPIO_Pin_8);

        if(x&0x10)
        GPIO_SetBits(GPIOE, GPIO_Pin_7);
        else
    GPIO_ResetBits(GPIOE, GPIO_Pin_7);

        if(x&0x20)
        GPIO_SetBits(GPIOB, GPIO_Pin_1);
        else
    GPIO_ResetBits(GPIOB, GPIO_Pin_1);

         if(x&0x40)
        GPIO_SetBits(GPIOB, GPIO_Pin_0);
        else
    GPIO_ResetBits(GPIOB, GPIO_Pin_0);

        if(x&0x80)
        GPIO_SetBits(GPIOC, GPIO_Pin_5);
        else
    GPIO_ResetBits(GPIOC, GPIO_Pin_5);

}
lizye 发表于 2017-8-27 19:07 | 显示全部楼层
H245_0;
        LCD_E0;
        Delayus(1);
        LCD_RW0; //WRITE
        Delayus(1);
        LCD_DI1; //DATA
        Delayus(1);
        LCD_E1;
        Delayus(1);

          DATA(*portValue);
        Delayus(1);
        LCD_E0;
 楼主| wyjie 发表于 2017-8-27 19:08 | 显示全部楼层
谢谢分享!在学习的过程中发现,MSP430的IO端口并不是只能通过位屏蔽来进行位操作的,不可以单独的位操作,(以16x系列为例)在io430x16x.h头文件中,有我们上面讨论的联合体、结构体的套用的函数,可以直接进行位操作
您需要登录后才可以回帖 登录 | 注册

本版积分规则

927

主题

12706

帖子

5

粉丝
快速回复 在线客服 返回列表 返回顶部

927

主题

12706

帖子

5

粉丝
快速回复 在线客服 返回列表 返回顶部