一段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,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,0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xFF,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
|