标题:
c8051F340单片机程序
[打印本页]
作者:
fzulyh
时间:
2018-5-12 12:18
标题:
c8051F340单片机程序
汉字取模软件,有需要的可以下载
单片机源程序如下:
#include "c8051F340.h"
#include <intrins.h>
#include<absacc.h>
#include<stdlib.h>
#include<MMC_SD\MMC_SD.h>
#include<main.h>
#include<lcd\lcd_control.h>
#include "USB_API.h"
#define White 0xFFFF
#define Black 0x0000
#define Blue 0x001F
#define Blue2 0x051F
#define Red 0xF800
#define Magenta 0xF81F
#define Green 0x07E0
#define Cyan 0x7FFF
#define Yellow 0xFFE0
sbit GO=P1^5;
uint8 Packet[64]; // Last packet received from host
uint8 nd,pic;
uint16 bf;
uint32 sd;
/********************************************************************************/
code const UINT USB_VID = 0x10C4;
code const UINT USB_PID = 0xEA61;
code const BYTE USB_MfrStr[] = {0x1A,0x03,'S',0,'i',0,'l',0,'i',0,'c',0,'o',0,'n',0,' ',0,'L',0,'a',0,'b',0,'s',0}; // Manufacturer String
code const BYTE USB_ProductStr[] = {0x10,0x03,'U',0,'S',0,'B',0,' ',0,'A',0,'P',0,'I',0}; // Product Desc. String
code const BYTE USB_SerialStr[] = {0x0a,0x03,'1',0,'2',0,'3',0,'4',0};
code const BYTE USB_MaxPower = 15; // Max current = 30 mA (15 * 2)
code const BYTE USB_PwAttributes = 0x80; // Bus-powered, remote wakeup not supported
code const UINT USB_bcdDevice = 0x0100; // Device release number 1.00
/********************************************************************************/
extern void wr_com(unsigned int i,unsigned int j) ;
//extern void uint8 image[3200];
extern void LCD_PutString(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int bColor) ;
extern void PutGB3232(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor);
void Suspend_Device(void);
void Init_Devices(void);
void Initialize(void);
void load_data(void);
void Wait(void);
/********************************************************************************/
void main(void)
{
// int i,j,k;
sd=1;
bf=0;
nd=0;
pic=0;
Init_Devices();
MMC_SD_ReadSingleBlock(0);
while(1)
{
// load_data();
Display_color(0x07e0);
delay(7000);
PutGB3232(20,40,"亮",Red,Green);delay(100);
PutGB3232(60,40,"邦",Red,Green);delay(100);
PutGB3232(20,80,"科",Blue,Green);delay(100);
PutGB3232(60,80,"技",Blue,Green);delay(100);
PutGB3232(20,120,"欢",Blue,Green);delay(100);
PutGB3232(60,120,"迎",Blue,Green);delay(100);
//PutGB3232(260,40,"你",Blue,Green);delay(100);
//PutGB3232(300,40,"!",Blue,Green);delay(100);
Wait();
Display_color(0x8410);
delay(6000);
Wait();
Display_color(0x07e0);
delay(6000);
Display_color(0x001f);
delay(6000);
Display_color(0xffff);
delay(6000);
Display_color(0x0000);
delay(6000);
}
}
//---------------------------------------------------------------------------------//
void Wait()
{
while(1)
{
if(GO==0)
{
delay(200);
while(GO==0)
return;
}
load_data();
}
}
//---------------------------------------------------------------------------------//
void load_data(void)
{
uint8 st[1],retry;
st[0]=1;
if(nd==1)
while(1)
{
if(nd==1)
{
for(retry=0;retry<64;retry+=2)
{
write_dc(Packet[retry], Packet[retry+1]);
buffer[bf++]=Packet[retry];
buffer[bf++]=Packet[retry+1];
if(bf==512)
{
MMC_SD_WriteSingleBlock(sd++);
buffer[0]=pic;
MMC_SD_WriteSingleBlock(0); //统计图片数量 buffer[0]=pi
bf=0;
}
}
nd=0;
Block_Write(st, 1);
}
}
}
//---------------------------------------------------------------------------------//
void USB_API_TEST_ISR(void) interrupt 17
{
uint8 INTVAL = Get_Interrupt_Source();
if (INTVAL & RX_COMPLETE)
{
Block_Read(Packet, 64);
nd=1;
}
if (INTVAL & DEV_SUSPEND)
{
Suspend_Device();
}
if (INTVAL & DEV_CONFIGURED)
{
Initialize();
}
if (INTVAL & DEVICE_OPEN)
{
goto_start();
}
if (INTVAL & DEVICE_CLOSE)
{
pic=pic+1;
goto_start();
}
}
/********************************************************************************/
void Initialize(void)
{
uint8 n;
PCA0MD &= ~0x40;
//------OSC--------------------------
OSCICN = 0x83;
CLKMUL=0X00;
CLKMUL|=0X80;
for(n=0;n<255;n++);
CLKMUL|=0Xc0;
while((0X20&CLKMUL)!=0X20);
CLKSEL = 0x00;
RSTSRC |= 0x02;
//------POINT--------------------------
P0MDIN |= 0xfF; // P0 pins 0-3 set high impedance
P0MDOUT |= 0xfF;
P1MDOUT |= 0xfF; // P1 pins 0-3 set high impedance
P1MDIN |= 0xfF;
P2MDOUT |= 0xff;
P3MDOUT |= 0xff;
P4MDOUT |= 0xff; // Port 1 pin 7 skipped by crossbar
XBR0 = 0x02;
XBR1 = 0x40; // Enable Crossbar
}
void Init_Devices(void)
……………………
…………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
汉字程序.zip
(162.65 KB, 下载次数: 17)
2018-5-12 12:18 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
lyMarvin
时间:
2018-5-22 09:46
请问楼主,这个有原理图吗,显示用的是320240的屏?
作者:
shiyakuo
时间:
2022-8-2 06:47
高手 谢谢
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1