学习定时器中,液晶没显示,不知道什么问题,求大大指导。板子是Stm8l152 LP
#include <stm8l15x.h>
#include <stm8l152.h>
#define push (GPIO_ReadInputData(GPIOC))
void CLK_CONFIG(void)
{
CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_16); //HSI16分频,1MHz
CLK_PeripheralClockConfig(CLK_Peripheral_TIM1,ENABLE);
}
void LCD_GLASS_Init(void)
{
CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE);
LCD_Init(LCD_Prescaler_2, LCD_Divider_16, LCD_Duty_1_4,
LCD_Bias_1_3, LCD_VoltageSource_Internal);
LCD_PortMaskConfig(LCD_PortMaskRegister_0, 0xFF);
LCD_PortMaskConfig(LCD_PortMaskRegister_1, 0xFF);
LCD_PortMaskConfig(LCD_PortMaskRegister_2, 0xFF);
LCD_PortMaskConfig(LCD_PortMaskRegister_3, 0xFF);
LCD_ContrastConfig(LCD_Contrast_3V3);
LCD_DeadTimeConfig(LCD_DeadTime_0);
LCD_PulseOnDurationConfig(LCD_PulseOnDuration_1);
LCD_Cmd(ENABLE);
}
void TIM4_CONFIG(void)
{
TIM4_ITConfig(TIM4_IT_Update,ENABLE);
TIM4_TimeBaseInit(TIM4_Prescaler_8,125);
TIM4_Cmd(ENABLE);
}
main()
{
_asm("sim");
CLK_CONFIG();
LCD_GLASS_Init();
TIM4_CONFIG();
_asm("rim");
while(1);
}
#include <stm8l15x.h>
//#define push (GPIO_ReadInputData(GPIOC))
typedef void @far (*interrupt_handler_t)(void);
struct interrupt_vector {
unsigned char interrupt_instruction;
interrupt_handler_t interrupt_handler;
};
@far @interrupt void NonHandledInterrupt (void)
{
return;
}
@far @interrupt void TIM4_TEST(void)
{
static u8 i,j;
i++;
if(i==1000)
{
i=0;
j++;
switch(j)
{
case 0:
{
LCD_WriteRAM(LCD_RAMRegister_0,0x0f);
LCD_WriteRAM(LCD_RAMRegister_3,0xf0);
LCD_WriteRAM(LCD_RAMRegister_7,0x0f);
LCD_WriteRAM(LCD_RAMRegister_10,0xf0);
}
case 1:
{
LCD_WriteRAM(LCD_RAMRegister_1,0x0f);
LCD_WriteRAM(LCD_RAMRegister_4,0xf0);
LCD_WriteRAM(LCD_RAMRegister_8,0x0f);
LCD_WriteRAM(LCD_RAMRegister_11,0xf0);
}
case 2:
{
LCD_WriteRAM(LCD_RAMRegister_2,0x0f);
LCD_WriteRAM(LCD_RAMRegister_6,0xf0);
LCD_WriteRAM(LCD_RAMRegister_9,0x0f);
LCD_WriteRAM(LCD_RAMRegister_13,0xf0);
}
}
if(j==3)
j=0;
}
TIM4_ClearITPendingBit(TIM4_IT_Update);
}
extern void _stext(); /* startup routine */
struct interrupt_vector const _vectab[] = {
{0x82, (interrupt_handler_t)_stext}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 */
{0x82, NonHandledInterrupt}, /* irq1 */
{0x82, NonHandledInterrupt}, /* irq2 */
{0x82, NonHandledInterrupt}, /* irq3 */
{0x82, NonHandledInterrupt}, /* irq4 */
{0x82, NonHandledInterrupt}, /* irq5 */
{0x82, NonHandledInterrupt}, /* irq6 */
{0x82, NonHandledInterrupt}, /* irq7 */
{0x82, NonHandledInterrupt}, /* irq8 */
{0x82, NonHandledInterrupt}, /* irq9 */
{0x82, NonHandledInterrupt}, /* irq10 */
{0x82, NonHandledInterrupt}, /* irq11 */
{0x82, NonHandledInterrupt}, /* irq12 */
{0x82, TIM4_TEST}, /* irq13 */
{0x82, NonHandledInterrupt}, /* irq14 */
{0x82, NonHandledInterrupt}, /* irq15 */
{0x82, NonHandledInterrupt}, /* irq16 */
{0x82, NonHandledInterrupt}, /* irq17 */
{0x82, NonHandledInterrupt}, /* irq18 */
{0x82, NonHandledInterrupt}, /* irq19 */
{0x82, NonHandledInterrupt}, /* irq20 */
{0x82, NonHandledInterrupt}, /* irq21 */
{0x82, NonHandledInterrupt}, /* irq22 */
{0x82, NonHandledInterrupt}, /* irq23 */
{0x82, NonHandledInterrupt}, /* irq24 */
{0x82, NonHandledInterrupt}, /* irq25 */
{0x82, NonHandledInterrupt}, /* irq26 */
{0x82, NonHandledInterrupt}, /* irq27 */
{0x82, NonHandledInterrupt}, /* irq28 */
{0x82, NonHandledInterrupt}, /* irq29 */
}; |
|