S3C2440-AD应用

发布者:数字航海家最新更新时间:2015-04-09 来源: cechina关键字:S3C2440  AD应用  模拟传感器 手机看文章 扫描二维码
随时随地手机看文章
使用电位器模拟传感器,进行模数转化,将AD值转化为温度值,实时显示在LCD上。汉字使用48*48字模,字符使用24*48字模。通过软件PCtoLCD2002提取字模。这里主要用到ADCCON寄存器。首先要使能预分频器,因为太快会没转化完,所以降低频率,设置分频比,然后是选择模拟输入通道。然后启动AD转换,该位在开始后自动清零,通过ECFLG位检查是否转化结束。ADCDAT0低10位用来存放转化来的数据。
 
#include "2440addr.h"    
//垂直同步信号的脉宽、后肩和前肩      
#define VSPW       15      
#define VBPD       3      
#define VFPD       5       
//水平同步信号的脉宽、后肩和前肩      
#define HSPW       8      
#define HBPD       58      
#define HFPD      15      
#define CLKVAL 10      
#define HOZVAL 319      
#define LINEVAL 239      
#define PWREN 1      
#define MMODE 0      
#define PNRMODE 3      
#define BPPMODE 13      
#define INVVCLK 0      
#define INVVD 0      
#define INVVDEN 0       
#define U32 unsigned int       
#define M5D(n) ((n) & 0x1fffff)      
#define PAGEWIDTH 320      
#define OFFSIZE 0      
#define LCD_XSIZE 320      
#define LCD_YSIZE 240      
#define SCR_XSIZE 320      
#define SCR_YSIZE 240      
#define INVVLINE  1          
#define INVVFRAME 1           
#define BPP24BL 0      
#define BSWP 0      
#define HWSWP 0       
volatile U32 LCD_BUFFER[240][320];       
      
//48*48    
unsigned char wen[] = {                                                              //温    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x20,0x00,0x0C,0x00,0x01,0x80,    
0x38,0x00,0x1E,0x00,0x01,0xE0,0x3F,0xFF,0xFF,0x00,0x00,0xE0,0x38,0x00,0x0C,0x00,    
0x00,0xF0,0x38,0x00,0x0C,0x00,0x00,0x70,0x38,0x00,0x0C,0x00,0x00,0x70,0xB8,0x00,    
0x0C,0x00,0x00,0x21,0x38,0x00,0x0C,0x00,0x00,0x01,0x38,0x00,0x0C,0x00,0x00,0x01,    
0x3F,0xFF,0xFC,0x00,0x00,0x02,0x38,0x00,0x0C,0x00,0x30,0x02,0x38,0x00,0x0C,0x00,    
0x1C,0x06,0x38,0x00,0x0C,0x00,0x0E,0x04,0x38,0x00,0x0C,0x00,0x0F,0x04,0x38,0x00,    
0x0C,0x00,0x07,0x08,0x38,0x00,0x0C,0x00,0x07,0x08,0x38,0x00,0x0C,0x00,0x03,0x18,    
0x3F,0xFF,0xFC,0x00,0x03,0x10,0x38,0x00,0x0C,0x00,0x00,0x30,0x38,0x00,0x0C,0x00,    
0x00,0x30,0x20,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x00,    
0x01,0x80,0x00,0x61,0xFF,0xFF,0xFF,0xC0,0x00,0xC1,0xC1,0x81,0x83,0xC0,0x00,0xC1,    
0xC1,0x81,0x83,0x80,0x01,0xC1,0xC1,0x81,0x83,0x80,0x43,0x81,0xC1,0x81,0x83,0x80,    
0x3F,0x81,0xC1,0x81,0x83,0x80,0x07,0x81,0xC1,0x81,0x83,0x80,0x03,0x01,0xC1,0x81,    
0x83,0x80,0x03,0x01,0xC1,0x81,0x83,0x80,0x03,0x01,0xC1,0x81,0x83,0x80,0x03,0x01,    
0xC1,0x81,0x83,0x80,0x07,0x01,0xC1,0x81,0x83,0x80,0x07,0x01,0xC1,0x81,0x83,0x80,    
0x07,0x01,0xC1,0x81,0x83,0x90,0x07,0x01,0xC1,0x81,0x83,0xB8,0x07,0x81,0xC1,0x81,    
0x83,0xBC,0x01,0x7E,0x3E,0x7E,0x7C,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};     
     
unsigned char du[] = {                                                               //度    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,    
0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,    
0x00,0xF0,0x00,0x00,0x01,0x00,0x00,0x70,0x00,0x40,0x01,0x80,0x00,0x60,0x00,0xE0,    
0x01,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0xC0,0x10,0x00,    
0x80,0x00,0x00,0xC0,0x1C,0x00,0xE0,0x00,0x00,0xC0,0x1E,0x00,0xF0,0x00,0x00,0xC0,    
0x1C,0x00,0xE0,0x00,0x00,0xC0,0x1C,0x00,0xE0,0x40,0x00,0xC0,0x1C,0x00,0xE0,0xE0,    
0x00,0xDF,0xFF,0xFF,0xFF,0xF0,0x00,0xC8,0x1C,0x00,0xE0,0x00,0x00,0xC0,0x1C,0x00,    
0xE0,0x00,0x01,0xC0,0x1C,0x00,0xE0,0x00,0x01,0xC0,0x1C,0x00,0xE0,0x00,0x01,0xC0,    
0x1C,0x00,0xE0,0x00,0x01,0xC0,0x1C,0x00,0xE0,0x00,0x01,0xC0,0x1F,0xFF,0xE0,0x00,    
0x01,0xC0,0x1C,0x00,0xE0,0x00,0x01,0xC0,0x10,0x00,0x80,0x00,0x01,0xC0,0x00,0x00,    
0x10,0x00,0x01,0x80,0x00,0x00,0x38,0x00,0x01,0x81,0xFF,0xFF,0xFC,0x00,0x01,0x80,    
0x08,0x00,0x78,0x00,0x01,0x80,0x0C,0x00,0x70,0x00,0x03,0x80,0x06,0x00,0xE0,0x00,    
0x03,0x00,0x03,0x01,0xC0,0x00,0x03,0x00,0x03,0x03,0xC0,0x00,0x03,0x00,0x01,0x87,    
0x80,0x00,0x03,0x00,0x00,0xCF,0x00,0x00,0x06,0x00,0x00,0x7E,0x00,0x00,0x06,0x00,    
0x00,0x3C,0x00,0x00,0x06,0x00,0x00,0x7C,0x00,0x00,0x0C,0x00,0x01,0xFF,0x00,0x00,    
0x0C,0x00,0x03,0xC7,0xE0,0x00,0x08,0x00,0x0F,0x01,0xFE,0x00,0x18,0x00,0x78,0x00,    
0x7F,0xF8,0x10,0x03,0xE0,0x00,0x1F,0xE0,0x20,0x1E,0x00,0x00,0x03,0xC0,0x20,0xE0,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};    
unsigned char s1[] = {                                                               //:    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0xE0,0x00,0x00,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0x00,0x03,0xF8,0x00,0x00,    
0x00,0x00,0x03,0xF8,0x00,0x00,0x00,0x00,0x03,0xF8,0x00,0x00,0x00,0x00,0x01,0xF0,    
0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0x00,0x03,0xF8,    
0x00,0x00,0x00,0x00,0x03,0xF8,0x00,0x00,0x00,0x00,0x03,0xF8,0x00,0x00,0x00,0x00,    
0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};    
unsigned char s2[] = {                                                               //℃    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x98,0x00,0xFF,0x80,0x00,    
0x03,0x0C,0x03,0xFF,0xE0,0x00,0x02,0x0C,0x0F,0x80,0x38,0x80,0x02,0x0C,0x1E,0x00,    
0x0C,0x80,0x03,0x0C,0x3C,0x00,0x06,0x80,0x03,0x18,0x38,0x00,0x03,0x80,0x01,0xF8,    
0x70,0x00,0x01,0x80,0x00,0x00,0xF0,0x00,0x01,0x80,0x00,0x00,0xE0,0x00,0x01,0x80,    
0x00,0x01,0xE0,0x00,0x00,0x80,0x00,0x01,0xC0,0x00,0x00,0x80,0x00,0x01,0xC0,0x00,    
0x00,0x80,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x03,    
0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,    
0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,    
0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x01,    
0xC0,0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,    
0x00,0x00,0xE0,0x00,0x00,0x80,0x00,0x00,0xF0,0x00,0x01,0x80,0x00,0x00,0x78,0x00,    
0x01,0x00,0x00,0x00,0x38,0x00,0x02,0x00,0x00,0x00,0x3C,0x00,0x0E,0x00,0x00,0x00,    
0x1F,0x00,0x38,0x00,0x00,0x00,0x0F,0xE1,0xF0,0x00,0x00,0x00,0x03,0xFF,0xC0,0x00,    
0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};    
//24*48    
unsigned char num[] = {    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                             //0    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x0F,0xFF,0xF8,0x0F,0xFF,0xF8,0x0F,0xFF,0xF0,    
0x0E,0x00,0x30,0x08,0x00,0x60,0x18,0x00,0x40,0x10,0x00,    
0xC0,0x10,0x00,0x80,0x00,0x01,0x80,0x00,0x01,0x00,0x00,    
0x03,0x00,0x00,0x02,0x00,0x00,0x06,0x00,0x00,0x04,0x00,    
0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x18,0x00,0x00,0x18,    
0x00,0x00,0x38,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,    
0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,    
0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0xF0,    
0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0x70,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                              //1    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x04,0x00,0x00,0x0C,0x00,0x00,0x1C,0x00,    
0x03,0xFC,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,    
0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,    
0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,    
0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,    
0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,    
0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,    
0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,    
0x00,0x00,0x1C,0x00,0x00,0x3E,0x00,0x03,0xFF,0xE0,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                              //2    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x7E,0x00,0x01,0x83,0x80,0x06,0x01,0xC0,    
0x0C,0x00,0xE0,0x0C,0x00,0xE0,0x1C,0x00,0x70,0x1C,0x00,    
0x70,0x1C,0x00,0x70,0x1E,0x00,0x70,0x1E,0x00,0x70,0x0E,    
0x00,0x70,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x01,0xC0,    
0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x0E,    
0x00,0x00,0x1C,0x00,0x00,0x38,0x00,0x00,0x70,0x00,0x00,    
0xE0,0x00,0x01,0xC0,0x00,0x01,0x80,0x00,0x03,0x00,0x10,    
0x06,0x00,0x10,0x0C,0x00,0x30,0x18,0x00,0x30,0x10,0x00,    
0x60,0x3F,0xFF,0xE0,0x3F,0xFF,0xE0,0x3F,0xFF,0xE0,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                              //3    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x7E,0x00,0x01,0x83,0x80,0x03,0x01,0xC0,    
0x06,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0x70,0x0F,0x00,    
0x70,0x0F,0x00,0x70,0x07,0x00,0x70,0x00,0x00,0x70,0x00,    
0x00,0x60,0x00,0x00,0xE0,0x00,0x00,0xC0,0x00,0x01,0x80,    
0x00,0x07,0x00,0x00,0x7C,0x00,0x00,0x07,0x80,0x00,0x00,    
0xC0,0x00,0x00,0x60,0x00,0x00,0x70,0x00,0x00,0x30,0x00,    
0x00,0x38,0x00,0x00,0x38,0x0C,0x00,0x38,0x1E,0x00,0x38,    
0x1E,0x00,0x38,0x1E,0x00,0x30,0x1C,0x00,0x70,0x0C,0x00,    
0x60,0x06,0x00,0xC0,0x03,0x03,0x80,0x00,0xFE,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                             //4    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x01,0x80,0x00,0x03,0x80,0x00,0x03,0x80,    
0x00,0x07,0x80,0x00,0x0F,0x80,0x00,0x0B,0x80,0x00,0x1B,    
0x80,0x00,0x13,0x80,0x00,0x33,0x80,0x00,0x63,0x80,0x00,    
0x43,0x80,0x00,0xC3,0x80,0x01,0x83,0x80,0x01,0x03,0x80,    
0x03,0x03,0x80,0x02,0x03,0x80,0x04,0x03,0x80,0x0C,0x03,    
0x80,0x08,0x03,0x80,0x18,0x03,0x80,0x30,0x03,0x80,0x3F,    
0xFF,0xFC,0x3F,0xFF,0xFC,0x00,0x03,0x80,0x00,0x03,0x80,    
0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,    
0x80,0x00,0x03,0x80,0x00,0x03,0xC0,0x00,0x7F,0xFC,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                          //5    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x07,0xFF,0xF0,0x07,0xFF,0xF0,0x07,0xFF,0xF0,    
0x04,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00,0x04,0x00,    
0x00,0x04,0x00,0x00,0x08,0x00,0x00,0x08,0x00,0x00,0x08,    
0x00,0x00,0x08,0x7F,0x00,0x09,0xFF,0x80,0x0B,0x81,0xC0,    
0x0E,0x00,0xE0,0x0E,0x00,0x70,0x0C,0x00,0x70,0x00,0x00,    
0x78,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,    
0x00,0x38,0x0C,0x00,0x38,0x1E,0x00,0x38,0x1E,0x00,0x38,    
0x1E,0x00,0x30,0x1C,0x00,0x70,0x0C,0x00,0x70,0x0C,0x00,    
0xE0,0x06,0x00,0xC0,0x03,0x83,0x80,0x00,0xFE,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                            //6    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x3F,0x00,0x00,0xC1,0xC0,0x01,0x81,0xC0,    
0x03,0x01,0xE0,0x06,0x01,0xE0,0x0C,0x01,0xE0,0x0C,0x00,    
0x00,0x0C,0x00,0x00,0x1C,0x00,0x00,0x18,0x00,0x00,0x18,    
0x00,0x00,0x38,0x00,0x00,0x38,0x3F,0x00,0x38,0xFF,0xC0,    
0x3B,0xC1,0xE0,0x3B,0x00,0xE0,0x3E,0x00,0x70,0x3C,0x00,    
0x70,0x38,0x00,0x38,0x38,0x00,0x38,0x38,0x00,0x38,0x38,    
0x00,0x38,0x38,0x00,0x38,0x18,0x00,0x38,0x1C,0x00,0x38,    
0x1C,0x00,0x38,0x0C,0x00,0x30,0x0E,0x00,0x70,0x06,0x00,    
0x60,0x03,0x00,0xC0,0x01,0xC1,0x80,0x00,0x7E,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                             //7    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x0F,0xFF,0xF8,0x0F,0xFF,0xF8,0x0F,0xFF,0xF0,    
0x0E,0x00,0x30,0x08,0x00,0x60,0x18,0x00,0x40,0x10,0x00,    
0xC0,0x10,0x00,0x80,0x00,0x01,0x80,0x00,0x01,0x00,0x00,    
0x03,0x00,0x00,0x02,0x00,0x00,0x06,0x00,0x00,0x04,0x00,    
0x00,0x0C,0x00,0x00,0x0C,0x00,0x00,0x18,0x00,0x00,0x18,    
0x00,0x00,0x38,0x00,0x00,0x30,0x00,0x00,0x30,0x00,0x00,    
0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,    
0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0xF0,    
0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0x70,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                           //8    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0xFF,0x00,0x03,0x81,0xC0,0x07,0x00,0xE0,    
0x0E,0x00,0x70,0x0C,0x00,0x70,0x1C,0x00,0x38,0x1C,0x00,    
0x38,0x1C,0x00,0x38,0x1C,0x00,0x38,0x1E,0x00,0x38,0x0F,    
0x00,0x70,0x0F,0x80,0x70,0x07,0xC0,0xE0,0x03,0xF1,0xC0,    
0x01,0xFF,0x00,0x01,0xFF,0x00,0x03,0x1F,0x80,0x06,0x07,    
0xC0,0x0E,0x03,0xE0,0x1C,0x00,0xF0,0x1C,0x00,0xF0,0x38,    
0x00,0x78,0x38,0x00,0x38,0x38,0x00,0x38,0x38,0x00,0x38,    
0x38,0x00,0x38,0x38,0x00,0x38,0x1C,0x00,0x70,0x0C,0x00,    
0x60,0x06,0x00,0xE0,0x03,0x81,0x80,0x00,0xFE,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,                            //9    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0xFC,0x00,0x03,0x83,0x00,0x06,0x00,0x80,    
0x0E,0x00,0xC0,0x1C,0x00,0x60,0x1C,0x00,0x60,0x18,0x00,    
0x30,0x38,0x00,0x30,0x38,0x00,0x30,0x38,0x00,0x38,0x38,    
0x00,0x38,0x38,0x00,0x38,0x38,0x00,0x38,0x38,0x00,0x78,    
0x1C,0x00,0x78,0x1C,0x00,0xF8,0x1E,0x01,0xB8,0x0F,0x87,    
0x38,0x07,0xFE,0x38,0x01,0xF8,0x38,0x00,0x00,0x30,0x00,    
0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x60,    
0x00,0x00,0xE0,0x06,0x00,0xC0,0x0F,0x01,0xC0,0x0F,0x01,    
0x80,0x0F,0x03,0x00,0x07,0x0E,0x00,0x01,0xF8,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,    
0x00};    
void Delay(U32 x){    
    U32 i, j, k;    
    for(i = 0; i < x; i++)    
        for(j = 0; j < 0xff; j++)    
            for(k = 0; k < 0xff; k++)    
                ;    
}    
[page]   
void Init_LCD(){  
rLCDCON1=(CLKVAL<<8)|(MMODE<<7)|(PNRMODE<<5)|(BPPMODE<<1)|0;   //设置CLKVAL,VCLK=HCLK/[(CLKVAL+1)*2],决定VM的触发方式,选择显示模式和BPP模式,暂时不要开启LCD,因为还没有设置好
       rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW);    //rLCDCON2,rLCDCON3和rLCDCON4主要设置时序  
       rLCDCON3=(HBPD<<19)|(HOZVAL<<8)|(HFPD);  
       rLCDCON4=(HSPW);  
       rLCDCON5 = (BPP24BL<<12) | (INVVCLK<<10) | (INVVLINE<<9) | (INVVFRAME<<8) | (0<<7) | (INVVDEN<<6) | (PWREN<<3)  |(BSWP<<1) | (HWSWP);                         //INVVLINE和INVVFRAME需要进行翻转,因为CPU发出的是正脉冲,LCD使用的是负脉冲,所以要改变极性,PWREN使能电源信号
       rLCDSADDR1=(((U32)LCD_BUFFER>>22)<<21)|M5D((U32)LCD_BUFFER>>1);  
       rLCDSADDR2=M5D(((U32)LCD_BUFFER+(SCR_XSIZE*SCR_YSIZE*4))>>1 );  
       rLCDSADDR3=PAGEWIDTH*32/16;  
       rLCDINTMSK|=(3);        
       rTCONSEL = 0;             
       rGPCUP = 0x0;  
       rGPDCON = 0xaaaaaaaa;  
       rGPCCON = 0xaaaa02a9;  
       rGPDUP = 0x0;  
       rGPGUP=rGPGUP&("(1<<4))|(1<<4);        
       rGPGCON=rGPGCON&("(3<<8))|(3<<8);   
       rLCDCON1 |= 1;   //使能数据输出和LCD控制信号
}        
      
void Paint_text(U32 x, U32 y, U32 color, unsigned char ch[], U32 lengx, U32 lengy){  //我的这个函数是通用的,只要正确传递参数  
    int i, j, test, t = -1;       
    for(i = 0; i < lengy; i++){          
        for(j = 0; j < lengx; j++){       
            if(j%8 == 0){       
                test = 0x80;       
                t++;       
            }       
            if(ch[t] & test)       
                LCD_BUFFER[x+i][y+j] = color;       
            test >>= 1;          
        }         
    }       
}       
      
void Paint_background(U32 c, U32 startx, U32 starty, U32 endx, U32 endy){    
    U32 i,j;       
    for(j = starty; j < endy; j++)       
        for(i = startx; i < endx; i++)       
            LCD_BUFFER[j][ i] = c;       
}       
U32 readAD(U32 ch){    
    rADCCON = (1<<14)|(49<<6)|(ch<<3);    
    rADCCON |= 0x1;    
    while(rADCCON & 0x1);    
    while(!(rADCCON & 0x8000));    
    return ((U32)rADCDAT0 & 0x3ff)*99/0x3ff ;    
}    
      
int LcdMain(){    
    U32 temperature, pre[2];    
    pre[0] = pre[1] = 0;       
    Init_LCD();       
    Paint_background(0xFFFFFF,0,0,LCD_XSIZE,LCD_YSIZE);    
    Paint_text(100, 20, 0x0, wen, 48, 48);    
    Paint_text(100, 68, 0x0, du, 48, 48);    
    Paint_text(100, 116, 0x0, s1, 48, 48);    
    Paint_text(100, 212, 0x0, s2, 48, 48);    
    while(1){    
        temperature = readAD(0);                                       //读取温度  
        if(temperature / 10 != pre[1]){                               //如果温度改变了,调节LCD上显示的温度,如果没有改变跳过  
            pre[1] = temperature/10;    
            Paint_background(0xFFFFFF,164,100,164+24,100+48);    
            Paint_text(100, 164, 0x0, num+pre[1]*144,24,48);     //因为每个数字占24*48/8=144个字节,所以num+offset就可以定位    
        }    
        if(temperature %10 != pre[0]){    
            pre[0] = temperature%10;    
            Paint_background(0xFFFFFF,188,100,188+24,100+48);    
            Paint_text(100, 188, 0x0, num+pre[0]*144,24,48);                    
        }    
        Delay(100);    
    }       
}
关键字:S3C2440  AD应用  模拟传感器 引用地址:S3C2440-AD应用

上一篇:S3C2440-LCD字符显示
下一篇:S3C2440-LCD图片显示

推荐阅读最新更新时间:2024-03-16 13:57

S3C2440 启动流程及汇编代码知识
1、框架 2、启动过程 大多数ARM芯片从0地址启动 NOR启动:NOR Flash 基地址为0,片内 RAM 地址为 0X4000,0000 CPU 读出Nor上第一个指令(前四个字节),执行 CPU继续读出其他指令执行 Nand启动:片内 4K RAM 基地址为0,Nor Flash 不可访问 2440硬件把Nand前4K内容复制到片内 RAM 然后 CPU 从0地址取出第一条指令 例如:(汇编代码) ldr sp, =4096 /* nand启动 */ ldr sp, =0x40000000+4096 /* nor启动 */ 3、几条常用汇编指令 LDR: 读内存 LDR R0, 读取地
[单片机]
<font color='red'>S3C2440</font> 启动流程及汇编代码知识
S3C2440——使用URAT0中断方式发送和接收字符串
设置中断向量表 ;文件ASM_Interrupt.s ;(1)设置中断向量表 Mode_USR EQU 0x50 ;IRQ中断开放,FIQ中断关闭 Mode_FIQ EQU 0xD1 ;关闭IRQ、FIQ中断 Mode_IRQ EQU 0xD2 ;关闭IRQ、FIQ中断 Mode_SVC EQU 0xD3 ;关闭IRQ、FIQ中断 GET 2440Reg_addr.inc AREA MyCode, CODE,READONLY IMPORT Uart_Init IMPORT INT_UART0 ENTRY ;设置中断向量表 B
[单片机]
S3C2440启动代码执行顺序
一张mini2440启动代码执行顺序表
[单片机]
<font color='red'>S3C2440</font>启动代码执行顺序
ARM总线架构(S3C2440
S3C2440集成了丰富了外设控制器(LCD控制器、USB Device控制器、USB Host控制器、NAND FLASH控制器、I2C控制器、SPI控制器等)。要控制这些外设就要设置相应控制器的寄存器以产生相应的驱动时序。学习S3C2440,主要是如何配置寄存器。下面是S3C2440特殊功能寄存器地址: #define rBANKCON0 (*(volatileunsigned *)0x48000004) //Boot ROM control #define rBANKCON1 (*(volatileunsigned *)0x48000008) //BANK1 control #define rBANKCON2 (*(vo
[单片机]
ARM总线架构(<font color='red'>S3C2440</font>)
S3C2440学习笔记一 1.1ADS软件的安装
1 打开ads软件安装包 点击setup.exe文件 2点击next 直到遇到选择安装位置可以改变 3 点击next 直到安装license文件 这里选择安装文件中的license.dat文件 最后直到安装完成 查看安装是出现下面的内容表示安装好了
[单片机]
<font color='red'>S3C2440</font>学习笔记一 1.1ADS软件的安装
u-boot2009.11 s3c2440移植手记
奋战了好几天了 U-BOOT终于有点眉目了,虽然nandflash还没有弄好,目前还不支持从nandflash启动。先来张图片吧哈哈。 u-boot作为现在主流的bootloader同样分为boot 和 loader两部分。 boot:(靴子呵呵基础支撑作用)为第一阶段,主要是硬件设备的初始化。 loader:(装载机)为第二阶段完成初始化后将flash的内容搬运到内存ram中运行。 具体步骤我就不说了 网上很多大侠都说过了 我第一阶段boot的调试方法:点灯 (1)——cpu/arm920t/start.S 汇编 完成第一阶段后点一个灯,现象是LED1亮 (2)——board/..../xx2440.c 在init bo
[单片机]
u-boot2009.11 <font color='red'>s3c2440</font>移植手记
s3c2440之IIS(4)S3C2440的I2S控制器
一、I2S控制器结构框图 S3C2440A的Inter-IC Sound (IIS)总线接口作为一个编解码接口连接外部8/16位立体声音频解码IC用于迷你碟机和可携式应用。IIS总线接口支持IIS总线数据格式和MSB-justified数据格式。该接口对FIFO的访问采用了DMA模式取代了中断。它可以在同一时间接收和发送数据。 图1 结构框图 1 、总线接口,寄存器组和状态机(BRFC):总线接口逻辑和FIFO 访问由状态机控制。 2、5 位双预定标器(IPSR):一个预定标器用于IIS 总线接口的主时钟发生器,另外一个用作外部编解码时钟发生器。 3、64 位FI
[单片机]
<font color='red'>s3c2440</font>之IIS(4)<font color='red'>S3C2440</font>的I2S控制器
ADμC812在存储测试系统中的应用
   1 引言    ADμC812 是美国ADI(Analog Devicelnc)公司生产的高性能单片机,是全集成的12位数据采集系统。它在芯片内集成了高性能的自校准多通道 ADC (8通道12位高精度)、2个12位 DAC 以及可编程的8位MCU(与8051兼容)。片内有8kB的闪速/电擦除程序 存储 器和在线下载/调试/编程的功能、640B的闪速/电擦除数据存储器、256B片内数据存储器以及与8051兼容的内核。另外MCU支持的功能包括看门狗定时器、电源监视器以及ADCDMA功能。同时为多处理器接口和I/O扩展提供了32条可编程的I/O线、与12C兼容的串行口、SPI串行接口和标准UART串行接口。MCU内核和 模拟
[嵌入式]
小广播
添点儿料...
无论热点新闻、行业分析、技术干货……
设计资源 培训 开发板 精华推荐

最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

换一换 更多 相关热搜器件
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved