2995 views|2 replies

45

Posts

1

Resources
The OP

LM3S811 cooperates with CH451 to control the display of digital tube [Copy link]

lm3s811 with ch451 to control the display of digital tube, just adjusted yesterday

// Define the global system clock variable
unsigned long TheSysClock = 12000000UL;
// Define the pin
#define CH451_PERIPH SYSCTL_PERIPH_GPIOD
#define CH451_PORT GPIO_PORTD_BASE

//PD0-LOAD (send command on rising edge) PD1-DIN (input) PD2-DCLK (clock) PD3-DOUT (interrupt pin EINT1) If you only display the digital tube without the keyboard, you can not connect this pin


void ch451write(unsigned int command)
{
int i;
signed int a;
SysCtlDelay(50 * (TheSysClock / 3000)); // 延时约50ms
GPIOPinWrite(CH451_PORT, GPIO_PIN_0 , 0);
for(i=0;i<12;i++)
{
a=command&1;
if(a==1)
{
GPIOPinWrite(CH451_PORT, GPIO_PIN_1 , 0xff);
}
else
{
GPIOPinWrite(CH451_PORT, GPIO_PIN_1 , 0x0); //Din
}
GPIOPinWrite(CH451_PORT, GPIO_PIN_2 , 0x0);
command>>=1;
GPIOPinWrite(CH451_PORT, GPIO_PIN_2 , 0xff); //Dclk
}
GPIOPinWrite(CH451_PORT, GPIO_PIN_0 , 0x01); //Load 重要
}

void ch451_init()
{
SysCtlPeripheralEnable(CH451_PERIPH); // Enable the GPIO port where CH451 is located
GPIOPinTypeGPIOOutput(CH451_PORT, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2); // Set the pin where CH451 is located to output
GPIOPinTypeGPIOInput(CH451_PORT, GPIO_PIN_3); // Set the pin where CH451 is located to input
GPIOPinWrite(CH451_PORT, GPIO_PIN_1, 0x00); // First low then high select 4-wire input
GPIOPinWrite(CH451_PORT, GPIO_PIN_1, 0xff);

ch451write(0x201); //Reset
ch451write(0x401); //Open display
ch451write(0x580); //BCD decoding mode

}


void show(int value)
{
ch451write(0x0800|(value%10)); //ones digit
ch451write(0x0900|(value/10%10)); //tens digit
ch451write(0x0a00|(value/100%10)); //hundreds digit
ch451write(0x0b00|(value/1000)); //thousands digit

}

In the main function, call ch451_init() to initialize and show(val) to display the value.

This post is from Microcontroller MCU

Latest reply

Thanks for the selfless contribution! :kiss: I suggest that the author post more detailed information, such as the information of CH451, so that friends who have not come into contact with CH451 can check it more conveniently. Be a good person to the end, and send the Buddha to the west!  Details Published on 2011-12-13 14:02

赞赏

1

查看全部赞赏


3392

Posts

6

Resources
2
Thanks for the selfless contribution! :kiss: I suggest that the author post more detailed information, such as the information of CH451, so that friends who have not come into contact with CH451 can check it more conveniently. Be a good person to the end, and send the Buddha to the west!
This post is from Microcontroller MCU

45

Posts

1

Resources
3
Thanks to this friend for his advice CH451.pdf (305.75 KB, downloads: 17)
This post is from Microcontroller MCU

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list