OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 11583|回复: 2

请教LED点阵屏程序

[复制链接]

2

主题

6

帖子

0

精华

初级会员

Rank: 2

积分
171
金钱
171
注册时间
2011-10-13
在线时间
38 小时
发表于 2011-10-13 20:53:44 | 显示全部楼层 |阅读模式

一段LED点阵屏程序,08接口,在51单片机中能左移显示“欢迎光临”4个字,移植到STM32F100C8中不工作,请多指教!

#include "stm32f10x.h"

void GPIO_Config(void);
void NOP();
void  loadline(void);
void  sendline(void);
void  Loopline (void);

unsigned char BUF[];
unsigned char disp[ ];



/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name  : main
* Description    : Main program.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
int main(void)
{
   SystemInit();
   GPIO_Config();
    Loopline();
 
}

 

 

void NOP()
{
  ;
  ;
  ;
  ;
  ;
  ;
  ;           
  ;
 
}


//*****************装载一线点阵数据*****************//
void  loadline(void)
{
   u8 S;
   u8 word;
   u8 line;
   for(S=0;S<5;S++)    //5:要显示的4个字数+1
   {
      BUF[2*S+1]=disp[word+1+32*S+2*line];
      BUF[2*S]=disp[word+32*S+2*line];
   }
}

//*****************发送一线移动数据*****************//
void  sendline(void)
{
  u8 S;
  u8 P;
  u8 inc;
  u8 k;
  u8 j;
  u8 move;
  u8 m;
  u8 n;
  if(move<8)
     inc=0;
  else 
      inc=1;
  for(S=0+inc;S<8+inc;S++)
  {
       if(move<8)
        j=move;
       else
       j=move-8;
        k=(BUF[S+1]>>(8-j))|(BUF[S]<<j); 
    
     for(P=0<8++)
     {
         
         m=0;
          n=0;
          m=k;
          n=m&0x01;
        if(n==0)
       GPIO_SetBits(GPIOB , GPIO_Pin_11);
       else
       GPIO_ResetBits(GPIOB , GPIO_Pin_11);
       GPIO_SetBits(GPIOA , GPIO_Pin_8);
        NOP();  
         
          GPIO_ResetBits(GPIOA , GPIO_Pin_8);
           
         k>>=1;           //右移一位
     }
  }
}


void  Loopline (void)
{
      u8 i;
     u8 w;
     u8 y;
    u8 move;
    u8 word;
    u8 line16;

     move=0;
      word=0;
     
      while(1)
      {
        while(word<384)    //12*32=384
        {
          while(move<16)
          {
            for(i=0; i<8; i++)
            {
              for(line16=0; line16<16; line16++)
              {
                     GPIO_ResetBits(GPIOA , GPIO_Pin_11);
                     loadline( );
                     sendline( );
                    GPIO_ResetBits(GPIOA , GPIO_Pin_12);
                   GPIO_SetBits(GPIOA , GPIO_Pin_12);

                    w=0;
                     y=0;
                     w=line16;
                     y=w&0x01;
                     if(y==0)
                    GPIO_SetBits(GPIOB , GPIO_Pin_0);
                    else
                    GPIO_ResetBits(GPIOB , GPIO_Pin_0);
                    
                     w=0;
                     y=0;
                     w=line16;
                     y=w&0x02;
                     if(y==0)
                     GPIO_SetBits(GPIOB , GPIO_Pin_1);
                    
                     else
                     GPIO_ResetBits(GPIOB , GPIO_Pin_1);
                    
                     w=0;
                     y=0;
                    w=line16;
                     y=w&0x04;
                     if(y==0)
                     GPIO_SetBits(GPIOB , GPIO_Pin_2);
                    
                     else
                    GPIO_ResetBits(GPIOB , GPIO_Pin_2);
                    
                     w=0;
                     y=0;
                    w=line16;
                     y=w&0x08;
                     if(y==0)
                     GPIO_SetBits(GPIOB , GPIO_Pin_10);
                    
                     else
                     GPIO_ResetBits(GPIOB , GPIO_Pin_10);
                     GPIO_SetBits(GPIOA , GPIO_Pin_11);
                    
                    
              }
            }
            move++;
          }
          move=0;
          word=word+32;   //下一个字
        }
        word=0;
      }
}


unsigned  char    disp[]=

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 0xFF,0xFF,0xFF,0xFF,0xFF,0x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,0xFB,0xFF,0xFD,//光

0xFE,0xF7,0xFE,0xF7,0xDF,0x75,0x80,0x75,0xFF,0xB5,0xFE,0xD5,0xF9,0xE5,0xDB,0xF5,
0x80,0x15,0xDD,0xD5,0xDD,0xD5,0xDD,0xD5,0xDD,0xD5,0xDD,0xD7,0xC0,0x17,0xDF,0xD7,//临

 


 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,//空白

 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,//空白

 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,//空白

 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,//空白
};


void GPIO_Config(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
 
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |   RCC_APB2Periph_GPIOC |
                         RCC_APB2Periph_GPIOD , ENABLE);
      
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 |GPIO_Pin_11|GPIO_Pin_12;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);     

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_10|GPIO_Pin_11;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
}


#ifdef  USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *   where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif



 

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165371
金钱
165371
注册时间
2010-12-1
在线时间
2110 小时
发表于 2011-10-14 00:05:53 | 显示全部楼层
回复【楼主位】zhoumeng5623:
---------------------------------
要学会解决问题的方法.
移植这个东西有问题就从最底层查起,一点点查.

你现在不能移动.那么你能显示么?
要是连显示都显示不了,怎么移动?
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

46

主题

284

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
494
金钱
494
注册时间
2011-6-20
在线时间
0 小时
发表于 2011-10-15 11:17:26 | 显示全部楼层
这个两个例程是在51上运行的,所以你不能直接用的,我的列扫描你就不管那些数据是怎么来的了,不一样的电路有不同的程序。
看下原理就知道了。

静态显示.rar

8.7 KB, 下载次数: 538

字幕滚动程序.rar

18.27 KB, 下载次数: 446

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-2-24 07:08

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表