我的ATMEGA3290P驱动段式LCD程序,为什么点不亮?
我的ATMEGA3290P驱动段式LCD程序,为什么点不亮?初始化有问题吗?程序如下:
#include <avr/io.h>
//#include<avr/eeprom.h>
//#include<stdio.h>
//#include <avr/signal.h>
//#include <avr/pgmspace.h>
unsigned char mask = {
0b11000000,
0b00110000,
0b00001100,
0b00000011
};
//unsigned char shift = {0, 2 , 4, 6 };
unsigned char LCD_DisBuffer;
unsigned intNumberMap = {
0b11110110,
0b10100010,
0b11101101,
0b11101011,
0b10111010,
0b11011011,
0b11011111,
0b11100010,
0b11111111,
0b11111011
};
#define vref 1500
#define verf_zero 83
//uint8_t FHR100,FHR10,FHR1;
//extern uint8_t FHR ;
//uint16_tFHRLevel;
/*******************************************************************************
* Function Name : ConvertNum
* Description : ?????????????
* Inputs : InputNum--????
* Outputs : None
* Return : None
* Notes : None
*******************************************************************************/
void ConvertNum(unsigned int SPI_DATA)
{
unsigned int temp,Num=0;
unsigned char i,j;
unsigned int lcd_buffer;
temp=(unsigned int)(((unsigned long)((unsigned long)SPI_DATA*vref))/14745);
temp=temp-verf_zero;
for(i=0;i<4;i++)
{
Num=NumberMap;
for(j=0;j<4;j++)
{
lcd_buffer =Num & mask;
// temp2>>shift
//LCD_DisBuffer = LCD_DisBuffer |(unsigned char)( temp2>> (unsigned char)shift);
}
temp=temp/10;
switch (i)
{
case 0:
/* Enable the write access on the LCD RAM First banck */
// LCD->CR4 &= (uint8_t)~LCD_CR4_PAGECOM;
//COM0
LCD_DisBuffer=lcd_buffer;
LCD_DisBuffer=lcd_buffer<<2;
LCD_DisBuffer=lcd_buffer<<4;
LCD_DisBuffer=lcd_buffer<<6;
break;
case 1:
LCD_DisBuffer|=lcd_buffer>>2;
LCD_DisBuffer|=lcd_buffer;
LCD_DisBuffer|=lcd_buffer<<2;
LCD_DisBuffer|=lcd_buffer<<4;
break;
case 2:
LCD_DisBuffer|=lcd_buffer>>4;
LCD_DisBuffer|=lcd_buffer>>2;
LCD_DisBuffer|=lcd_buffer;
LCD_DisBuffer|=lcd_buffer<<2;
break;
case 3:
LCD_DisBuffer|=lcd_buffer>>6;
LCD_DisBuffer|=lcd_buffer>>4;
LCD_DisBuffer|=lcd_buffer>>2;
LCD_DisBuffer|=lcd_buffer;
break;
}
}
}
//uint16_t Num, tmp = 0;
//uint8_t i;
//if((InputNum>='0')&&(InputNum<='9'))
//{
//Num=NumberMap;
//}
// else
//{
// Num=0;
// }
//for(i = 0;i < 4; i++)
// {
// tmp = Num & mask;
// LCD_DisBuffer = (uint8_t)(tmp >> (uint8_t)shift);
// }
//}
void LCD_Init(void)
{
/* Use 32kHz crystal oscillator */
/* 1/3 Bias and 1/4 duty, SEG0:SEG28 is used as port pins */
LCDCRB = (1<<LCDCS) | (1<<LCDMUX1)| (1<<LCDMUX0)| (1<<LCDPM3)| (1<<LCDPM0);
/* Using 16 as prescaler selection and 7 as LCD Clock Divide */
/* gives a frame rate of 49 Hz */
LCDFRR = (1<<LCDCD2) | (1<<LCDCD1);
/* Set segment drive time to 150 ¦Ìs and output voltage to 3 V*/
LCDCCR = (1<<LCDDC1) | (1<<LCDCC3) ;
/* Enable LCD, default waveform and no interrupt enabled */
LCDCRA = (1<<LCDEN);
}
void LCD_update(void)
{
/* LCD Blanking and Low power waveform are unchanged. */
/* Update Display memory. */
LCDDR00 = LCD_DisBuffer;
LCDDR05 = LCD_DisBuffer;
LCDDR10 = LCD_DisBuffer;
LCDDR15 = LCD_DisBuffer;
}
int main (void)
{
PORTA = 0xFF;
DDRA= 0xFF;
PORTC = 0xFF;
DDRC= 0xFF;
PORD = 0xFF;
DDRD= 0xFF;
PORTG = 0xFF;
DDRG= 0xFF;
LCD_Init();
while(1)
{
unsigned int Output;
Output=0x0406;
ConvertNum(Output);//PRESSURE TO BE 0x0406;
LCD_update();
}
} 请问 你这个 MCU 的芯片你是哪里买的? 程序太长了,,没心思看,,
页:
[1]