打印

求助、、、、、、、、、、、ARM管脚定义?

[复制链接]
2879|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hanfei08131106|  楼主 | 2010-7-19 21:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
hanfei08131106|  楼主 | 2010-7-19 21:28 | 只看该作者
有错误,高人帮改?谢谢、、、、
#include "hw_ints.h"
#include "hw_memmap.h"
#include "hw_types.h"
#include "gpio.h"
#include "sysctl.h"
#include "cpu.h"
#include "interrupt.h"

#define uint unsigned int
#define uchar unsigned char

#define     YJ_PERIPH            SYSCTL_PERIPH_GPIOB                                     //LED外围   B端口作为通用输入/输出  宏定义
#define     YJ_PORT                   GPIO_PORTB_BASE                                                                 //(GPIO通用输入/输出_PORTBB端口_BASE基准)        
#define     RS                        GPIO_PIN_0                                   //  PB5控制D1      B端口的2脚            
#define     RW                    GPIO_PIN_1                                   //  PB5控制D1      B端口的4脚
#define     EN                    GPIO_PIN_2                                   //  PB5控制D1      B端口的6脚

#define     YJBUS_PERIPH            SYSCTL_PERIPH_GPIOD                                     //LED外围   B端口作为通用输入/输出  宏定义
#define     YJBUS_PORT                   GPIO_PORTD_BASE                                                                 //(GPIO通用输入/输出_PORTBB端口_BASE基准)   
//#define         aa       GPIOPinWrite(YJ_PORT ,0xff);  
   
#define         RS_L       GPIOPinWrite(YJ_PORT,RS ,0x00);                //ser管脚为低
#define         RW_L       GPIOPinWrite(YJ_PORT,RW ,0x00);                //SRCLK1管脚为低
#define         EN_L       GPIOPinWrite(YJ_PORT,EN ,0x00);                //SRCLK1管脚为低

#define         RS_H       GPIOPinWrite(YJ_PORT,RS ,0xff);                //ser管脚为高
#define         RW_H       GPIOPinWrite(YJ_PORT,RW ,0xff);                //SRCLK1管脚为高
#define         EN_H       GPIOPinWrite(YJ_PORT,EN ,0xff);                //SRCLK1管脚为高  



uchar LCDDISPLAY_ROW1[]={"   08131106    "};
uchar LCDDISPLAY_ROW2[]={" hapyy!!!!!!!  "};
/*
uchar   LED[ ]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xfe,0xbf};   //共阳极段码表说明
uint    i,j,k,n=0;                                                              //说明整数变量
uchar   aa,bb[]={2,0,1,0,0,6,1,1},cc=0xc0,dd;                                   // 8个数码管显示的数数组   
*/      
void Delay(uint t)
{
  while(t)t--;
}

void lcd_delay(unsigned int delaytime)
{
  while(delaytime)delaytime--;
}


void write_lcd_command(uchar write_command)
{
  lcd_delay(40);
  RS_L;
  RW_L;
  GPIOPinWrite(YJBUS_PERIPH,YJBUS_PORT,write_command);
  EN_H;
  EN_L;
}

void write_lcd_data(unsigned char write_data)
{
  lcd_delay(40);
  RS_H;
  RW_L;
  GPIOPinWrite(YJBUS_PERIPH,YJBUS_PORT,write_data);
  EN_H;
  EN_L;
}

void initize_lcd(void)
{
  uchar i;
  EN_L;
  for(i=200;i>0;i--)lcd_delay(248);
  write_lcd_command(0x3f);
  for(i=4;i>0;i--)lcd_delay(248);
  write_lcd_command(0x3f);
  write_lcd_command(0x0f);
  write_lcd_command(0x01);
  for(i=4;i>0;i--)lcd_delay(248);
  write_lcd_command(0x06);
}

void lcd_displaystr(uchar x,uchar y,uchar *str)
{
  switch(x)
    {
      case 0:
            write_lcd_command(0x80+y);
            break;
          case 1:
            write_lcd_command(0xc0+y);
            break;
        }
  while(*str)
    {
          write_lcd_data(*str);
          str++;
        }
}




int main(void)
{  
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_6MHZ);                                                                                  //SysCtlClockSet函数()系统时钟设置  采用主振荡器  外接6MHz晶振  不分频
   
    SysCtlPeripheralEnable(YJ_PERIPH);                                                                                  //sysctl的周边启用
        SysCtlPeripheralEnable(YJBUS_PERIPH);
   
    GPIOPinTypeGPIOOutput(YJ_PORT, RS);                                                                          //GPIO输出型的  (GPIO输出引脚:GPIO_PIN_2)
        GPIOPinTypeGPIOOutput(YJ_PORT, RW);                                                                  //GPIO输出型的  (GPIO输出引脚:GPIO_PIN_4)
        GPIOPinTypeGPIOOutput(YJ_PORT, EN);                                                                          //GPIO输出型的  (GPIO输出引脚:GPIO_PIN_6)
    GPIOPadConfigSet(YJ_PORT, RS, GPIO_STRENGTH_8MA_SC,                                          //GPIO_STRENGTH_8MA:GPIO输出强度8毫安
                     GPIO_PIN_TYPE_STD_WPU);   
           GPIOPadConfigSet(YJ_PORT, RW, GPIO_STRENGTH_8MA_SC,                                  //GPIO_STRENGTH_8MA:GPIO输出强度8毫安
                     GPIO_PIN_TYPE_STD_WPU);
        GPIOPadConfigSet(YJ_PORT, EN, GPIO_STRENGTH_8MA_SC,                                  //GPIO_STRENGTH_8MA:GPIO输出强度8毫安
                     GPIO_PIN_TYPE_STD_WPU);

                                    
  initize_lcd();

  write_lcd_command(0x80);
  uchar i;
  for(i=0;i<16;i++)
    {
      write_lcd_data(i+'A');
      Delay(60000);
      Delay(60000);
    }
  write_lcd_command(0xC0);
  for(i=0;i<16;i++)
    {
      write_lcd_data(i+'a');
      Delay(60000);
      Delay(60000);
    }

  lcd_displaystr(0,0,LCDDISPLAY_ROW1);
  Delay(60000);
  Delay(60000);
  lcd_displaystr(1,0,LCDDISPLAY_ROW2);
  while(1);
   
}

使用特权

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

本版积分规则

个人签名:适应环境,不要让环境去适应你、、

5

主题

144

帖子

1

粉丝