HT ide 3000 VPM software simulation button press digital display digital circuit construction and source code VPM application Series 5

Source: Internet
Author: User

1. Function Description: press the button and the digital tube starts from 0 to 9 and is reset to 0.

2. The Code is as follows: you are welcome to optimize it as the best code.

/*
Data: 20091010
For: button drive LED
Tool: Ht ide 3000 v7.0
MCU: HT48R50A-1
Fsys: 4 MHz
ASM/C: c
VPM: Yes
*/
# Include "self-HT48R50A-1.h"

// For Segs-Com0
# Define segsport _ Pa
# Define segsctrl _ pac
# Define ptrport _ pb6
# Define ptrctrl _ pbc6
# Define com0port _ pb7
# Define com0ctrl _ pbc7
// For button
# Define swport _ pc0 // Switch Port
# Define swctrl _ pcc0 // switch controlling

// Variable
Int icntbutton;
// Function
Int getswitchstatus (void );
Void blinksegs (INT );
// The main function
Void main (void)
{
Int I;
 
Segsport = 0x00; // turn off segs
Segsctrl = 0x00; // output
Com0ctrl = 0;
Ptrctrl = 0;
Com0port = 0;
Ptrport = 0;
Swctrl = 1; // Input
Icntbutton = 0;

While (1)
{
_ Delay( 10000 );

Getswitchstatus ();

Blinksegs (icntbutton );
}
}
// Function ==========================================
Int getswitchstatus ()
{
 
Swctrl = 1;
 
If (0 = swport)
{
Icntbutton ++;
Icntbutton = icntbutton % 10;
While (0 = swport)
{
_ Delay( 1000 );
}
Return 0xff;
}
 
Return 0x00;
}
// Function -----------------------------------
Void blinksegs (INT sum)
{
Char iblink;
Char segs [10] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f };
Iblink = segs [Sum];
 
Segsport = iblink;
}

// ================================================ ========

3. Simulation browsing address:

Http://p.blog.csdn.net/images/p_blog_csdn_net/duojinian/EntryImages/20091013/Segs_Driver_20091013.jpg

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.