ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á

QQ怬

Ö»ÐèÒ»²½£¬¿ìËÙ¿ªÊ¼

ËÑË÷
²é¿´: 4041|»Ø¸´: 0
ÊÕÆð×ó²à

Óõ¥Æ¬»ú¿ª·¢¿É¿¿µÄǶÈëʽÈí¼þÖ®ÊýÂë¹Ü

[¸´ÖÆÁ´½Ó]
ID:61444 ·¢±íÓÚ 2014-5-6 17:56 | ÏÔʾȫ²¿Â¥²ã |ÔĶÁģʽ
ÔÚÐí¶àǶÈëʽϵͳÖÐÌṩijЩÐÎʽµÄÏÔʾÉ豸ÓÃÀ´ÏòÓû§´«µÝÐÅÏ¢¡£ÏÔʾÆ÷¿ÉÒÔÓÐÒ»¸ö¼òµ¥µÄָʾµÆµ½Ò»¸öÏÔʾ¸´ÔÓͼÐεÄÒº¾§ÏÔʾÆ÷¡£ÀýÈ磺ÎÒÃdz£ÓõÄÏÔʾÆ÷¼þÓУºLEDµÆ¡¢ÊýÂë¹Ü¡¢µãÕóÆÁ¡¢LCDÆÁµÈ¡£
ÔÚ´ËÎÒÃÇÀ´·ÖÎöÒ»ÏÂÈçºÎʹÓÃ7¶ÎLEDÊýÂë¹Ü¡£
1¡¢LEDÏÔʾÆ÷¡£
·¢¹â¶þ¼«¹Ü£¬»òÕß³ÆÎªLED£¬ÊÇÒ»¸ö±¨µÀÌåÉ豸¡£µ±µçÁ÷Èçͼ1-1Ëùʾͨ¹ýËüµÄʱºò£¬¿ÉÒÔ²úÉú¿É¼ûµÄ¹â¡£LED·¢¹âµÄÁÁ¶ÈÓëͨ¹ýLEDµÄµçÁ÷Ç¿¶È³ÉÕý±È¡£³£¼ûµÄLEDµÆ¿ÉÒÔ²úÉúºì¹â¡¢»Æ¹â¡¢Â̹⡢À¶¹â¡£¶øºìÉ«ÊÇÎÒÃdz£¼ûµÄLEDµÆ¡£

ͼ1-1
2¡¢ÊýÂë¹Ü
ÊýÂë¹ÜÊǶà¸öLEDµÆ×é³ÉµÄÒ»¸öÏÔʾÆ÷¼þ¡£Èçͼ1-2Ëùʾ¡£´ÓͼÖÐÎÒÃÇ¿ÉÒÔ¿´³ö£¬Ò»¸öÊýÂë¹ÜÊÇÓÉA¡¢B¡¢C¡¢D¡¢E¡¢F¡¢G¡¢DP 8¸öLEDµÆ×é³ÉµÄ¡£ÆäÖÐA-GÓÃÀ´ÏÔʾÊý¾Ý£¬DPÓÃÀ´±íʾСÊýµã£¬Í¨³£ÎÒÃdzÆÕâÑùµÄÊýÂë¹ÜΪ7¶ÎʽÊýÂë¹Ü¡£Í¼1-3±íÃ÷ÁËÕâÑùµÄÊýÂë¹ÜÓë΢¿ØÖÆÆ÷µÄÁ¬½Ó·½Ê½¡£´ÓͼÖÐÎÒÃÇ¿ÉÒÔ¿´³ö¿ØÖÆÒ»¸öÊýÂë¹ÜÐèÒª8¸öGPIO¶Ë¿Ú¡£ÄÇô£¬ÎÒÃÇÊÔÏëһϣ¬Èç¹ûϵͳÖÐÓжà¸öÊýÂë¹Ü£¬Äǽ«»á·Ç³£ÀË·ÑÎÒÃǵÄGPIO¶Ë¿Ú¡£ÄÇÓÐûÓÐÒ»¸ö½ÚÊ¡¶Ë¿ÚµÄ·½·¨À´À©Õ¹LEDµÆÄØ¡£Í¼1-4ÃèÊöÁËÕâÖÖ·½·¨¡£

ͼ1-2 ͼ1-3

ͼ1-4
ͼ1-4ʹÓÃ16¸ö¶Ë¿ÚÀ©Õ¹ÁË8¸öÊýÂë¹Ü¡£ÎÒÃÇÀ´¿´Ò»ÏÂÔõôʹÓÃÕâ8¸öÊýÂë¹Ü¡£´ÓÉÏÃæµÄÃèÊöÎÒÃÇÖªµÀ£¬Èç¹ûÒªµãÁÁÒ»¸öLEDµÆ£¬Ö»ÐèÒªÔÚÊýÂë¹ÜµÄAÒý½ÅºÍ12Òý½ÅÖ®¼ä¼ÓÒ»¸öµçѹ¾ÍÐÐÁË£¬µ«ÊÇÄǸö¶Ë¿Ú½ÓµçÔ´µÄÕý¼«ÄØ£¿Èç¹ûA¶Ë¿ÚÐèÒª½ÓµçÔ´µÄÕý¼«£¬ÄÇôÕâ¸öÊýÂë¹Ü¾Í±»³ÆÎª¹²Ñô¼«ÊýÂë¹Ü£¬·´Ö®£¬Ôò³ÆÎª¹²Òõ¼«ÊýÂë¹Ü¡£Í¼ÖÐÃèÊöµÄÊǹ²Ñô¼«ÊýÂë¹Ü¡£
3¡¢ÊýÂë¹ÜµÄ¶¯Ì¬É¨Ãè³ÌÐò¡£
½ÓÏÂÀ´ÎÒÃÇÀ´¿´Ò»ÏÂÔõôʹÓÃÕâ¸ö8¸öÊýÂë¹Ü¡£ÔÚÕâÀïÎÒÃÇʹÓö¯Ì¬É¨ÃèµÄ·½·¨¡£¶¯Ì¬É¨Ãè¼´µÚÒ»¸öÊýÂë¹ÜÏÔʾһ¶Îʱ¼äºóµÚ¶þÊýÂë¹ÜÏÔʾ£¬µÚ¶þ¸öÊýÂë¹ÜÏÔʾһ¶Îʱ¼äºóµÚÈý¸öÊýÂë¹ÜÏÔʾ¡­¡­ÒÀ´ÎÏÔʾ¡£Èç¹ûÕâ¸öɨÃèµÄËÙ¶È×ã¹»¿ìµÄ»°£¬ÎÒÃÇÈâÑ۾͸оõ²»µ½ÊÇÔÚÒ»¸öÒ»¸öÏÔʾ£¬¶øÊÇÕûÌåÒ»¿éÏÔʾµÄ¡£ÄÇôÕâ¸öɨÃèËٶȶàÉÙºÏÊÊÄØ£¿Ò»°ãÎÒÃǵÄÕûÌåɨÃèʱ¼äÒª²»´óÓÚ20ms¡£ÎÒÃÇÕâÀïÓÐ8¸öÊýÂë¹Ü£¬ÄÇôÎÒÃÇ1¸öÊýÂë¹ÜµÄɨÃèʱ¼äÉ趨Ϊ2.5ms¡£
±¾ÕÂÎÒÃÇÒÔÏÔʾ0-7Õâ8¸öÊý×ÖÀ´Ê¹ÓÃÊýÂë¹Ü¡£

Èí¼þ±àд£º
#include "includes.h"

void main(void)
{
    INT8U i;
    DispInit();
    Timer0Init();
   
    for(i=0;i<DISP_N_DIG;i++)
    {
         DispHex(i,i);
         DispPoint(i);
    }
    while(1)
    {
        ;
    }
}
ÒÔÉÏÊÇmainÎļþµÄÄÚÈÝ£¬DispInit()Õâ¸öº¯Êý³õʼ»¯ÁËÊýÂë¹ÜËùʹÓõÄIO¶Ë¿Ú£¬²¢ÇҹرÕËùÓеÄÊýÂë¹ÜÏÔʾ¡£Timer0Init()Õâ¸öº¯Êý³õʼ»¯Á˶¨Ê±Æ÷£¬ÉèÖö¨Ê±Ê±¼äΪ2.5ms¡£ÎÒÃÇÕâÀïʹÓö¨Ê±Æ÷À´¶¨Ê±É¨ÃèÊýÂë¹Ü¡£DispHex(i,i)Õâ¸öº¯ÊýÉèÖÃÁËÔÙÄĸöÊýÂë¹ÜÉÏÏÔʾʲôÊý£¬´Ëº¯ÊýÄܹ»ÏÔʾʮÁù½øÖƵÄ0-F¡£DispPoint(i)Õâ¸öº¯ÊýʵÏÖÁËÏÔʾµã£¬²ÎÊýΪÄĸöÊýÂë¹ÜµÄµã¡£
DISP_N_DIG±íÃ÷ÁËϵͳÖÐÊýÂë¹ÜµÄÊýÁ¿£¬ÕâÊÇÒ»¸öºê¶¨Ò壬ÐèÒªÓû§×Ô¼ºÐ޸ġ£

¸ü¶àÏêÇé×Éѯ£º²ÜÀÏʦ QQ£º2859780203
                          À£ºTEL£º18948782707
#include "includes.h"
/*
*********************************************************************************************************
*                                            LOCAL VARIABLES
*********************************************************************************************************/
static INT8U DispDigMsk;          /* Bit mask used to point to next digit to display */
static INT8U DispSegTbl[DISP_N_DIG];  /* Segment pattern table for each digit to display*/
static INT8U DispSegTblIx;               /* Index into DispSegTbl[] for next digit to display */
/*
*********************************************************************************************************
*                             HEXADECIMAL to SEVEN-SEGMENT conversion table
*                                                             a
*                                                           ------
*                                                        f |      | b
*                                                         |  g   |
* Note: The segments are mapped as follows:                       ------
*                                                        e |      | c
*        a    b    c    d    e    f    g    h              |  d   |
*        --   --   --   --   --   --   --   --                     ------ .h
*        B0   B1   B2   B3   B4   B5   B6   B7
*********************************************************************************************************
*/
INT8U code DispHexToSegTbl[] = {      /* HEXADECIMAL to SEVEN-SEGMENT conversion*/
    0xC0,                              /* '0' */
    0xF9,                              /* '1' */
    0xA4,                              /* '2' */
    0xB0,                              /* '3' */
    0x99,                              /* '4' */
    0x92,                              /* '5' */
    0x82,                              /* '6' */
    0xF8,                              /* '7' */
    0x80,                              /* '8' */
    0x90,                              /* '9' */
    0x88,                              /* 'A' */
    0x83,                              /* 'B', Actually displayed as 'b' */
    0xC6,                              /* 'C' */
    0xA1,                              /* 'D', Actually displayed as 'd' */
    0x86,                              /* 'E' */
    0x8E                               /* 'F' */
};

void DispClrScr (void);
void DispInit (void);
void DispStatClr (INT8U dig, INT8U numbit);
void DispStatSet (INT8U dig, INT8U numbit);
void DispOutDig (INT8U msk);
void DispOutSeg (INT8U seg);
void DispInitPort (void);
void DispHex(INT8U dig,INT8U number);
void DispPoint(INT8U dig);

/*$PAGE*/
/*
*********************************************************************************************************
*                                          CLEAR THE DISPLAY
*
* Description: This function is called to clear the display.
* Arguments  : none
* Returns    : none
*********************************************************************************************************
*/
void  DispClrScr (void)
{
    INT8U i;
    for (i = 0;i < DISP_N_DIG;i++)
    {           
        /* Clear the screen by turning OFF all segments */
        DispSegTbl = DISP_CRUSH_SEG;
    }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                      DISPLAY DRIVER INITIALIZATION
*
* Description : This function initializes the display driver.
* Arguments   : None.
* Returns     : None.
*********************************************************************************************************
*/

void DispInit (void)
{
    DispInitPort();                    /* Initialize I/O ports used in display driver*/
    DispDigMsk   = (1<<(DISP_N_DIG-1));               
    DispSegTblIx = 0;
    DispClrScr();                      /* Clear the Display*/
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                        DISPLAY NEXT SEVEN-SEGMENT DIGIT
*
* Description: This function is called by DispMuxISR() to output the segments and select the next digit
*              to be multiplexed.  DispMuxHandler() is called by DispMuxISR() defined in LED_IA.ASM
* Arguments  : none
* Returns    : none
* Notes      : - You MUST supply the code to clear the interrupt source.  Note that with some
*                microprocessors (i.e. Motorola's MC68HC11), you must clear the interrupt source before
*                enabling interrupts.
*********************************************************************************************************
*/

void  DispMuxHandler (void)
{
DispOutSeg(DISP_CRUSH_SEG);              /*TurnOFFsegmentswhilechanging digits*/
    DispOutDig(DispDigMsk);                   /* Select next digit to display       */
    DispOutSeg(DispSegTbl[DispSegTblIx]);        /* Output digit's seven-segment pattern */
    if (DispSegTblIx == (DISP_N_DIG - 1)) {      /* Adjust index tonextseven-segmentpattern*/
        DispSegTblIx =    0;                     /* Index into first segments pattern*/
        DispDigMsk = (~(1<<(DISP_N_DIG-1)));/*0x80willselectthefirst seven-segment digit  */
    }
    else
    {
        DispSegTblIx++;
        DispDigMsk = ~DispDigMsk;
        DispDigMsk >>= 1;                        /* Select next digit */
        DispDigMsk = ~DispDigMsk;
    }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                         CLEAR STATUS SEGMENT
*
* Description: This function is called to turn OFF a single segment on the display.
* Arguments  : dig   is the position of the digit where the segment appears (0..DISP_N_DIG-1)
*              bit   is the segment bit to turn OFF (0..7)
* Returns    : none
*********************************************************************************************************
*/

void  DispStatClr (INT8U dig, INT8U numbit)
{
    DispSegTbl[dig] &= ~(1 << numbit);
}

/*
*********************************************************************************************************
*                                           SET STATUS SEGMENT
*
* Description: This function is called to turn ON a single segment on the display.
* Arguments  : dig   is the position of the digit where the segment appears (0..DISP_N_DIG-1)
*              bit   is the segment bit to turn ON (0..7)
* Returns    : none
*********************************************************************************************************
*/

void  DispStatSet (INT8U dig, INT8U numbit)
{
    DispSegTbl[dig] |= 1 << numbit;
}

/*$PAGE*/
/*
*********************************************************************************************************
*                            DISPLAY HEX NUMBER ON SEVEN-SEGMENT DISPLAY
*
* Description: This function is called to display hex number on the seven-segment display.
* Arguments  : dig   is the position of the first digit where the string will appear:
*                        0 for the first  seven-segment digit.
*                        1 for the second seven-segment digit.
*                        .  .   .     .     .      .      .
*                        .  .   .     .     .      .      .
*                        DISP_N_SS - 1 is the last seven-segment digit.
*              number     is the number to display
* Returns    : none
* Notes      : - Not all ASCII characters can be displayed on a seven-segment display.  Consult the
*                ASCII to seven-segment conversion table DispASCIItoSegTbl[].
*********************************************************************************************************
*/

void DispHex(INT8U dig,INT8U number)
{
DispSegTbl[dig] = DispHexToSegTbl[number];
}

void DispPoint(INT8U dig)
{
DispStatClr(dig,7);
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                        I/O PORTS INITIALIZATION
*
* Description: This is called by DispInit() to initialize the output ports used in the LED multiplexing.
* Arguments  : none
* Returns    : none
* Notes      : 74HC573  8 bit latches are used for both the segments and digits outputs.
*********************************************************************************************************
*/

void  DispInitPort (void)
{
    outp(DISP_PORT_SEG, DISP_CRUSH_SEG);              /* Turn OFF segments*/
    outp(DISP_PORT_DIG, DISP_CRUSH_DIG);              /* Turn OFF digits*/
}

/*
*********************************************************************************************************
*                                        DIGIT output
*
* Description: This function outputs the digit selector.
* Arguments  : msk    is the mask used to select the current digit.
* Returns    : none
*********************************************************************************************************
*/

void  DispOutDig (INT8U msk)
{
    outp(DISP_PORT_DIG, msk);
}

/*
*********************************************************************************************************
*                                        SEGMENTS output
*
* Description: This function outputs seven-segment patterns.
* Arguments  : seg    is the seven-segment pattern to output
* Returns    : none
*********************************************************************************************************
*/
void  DispOutSeg (INT8U seg)
{
    outp(DISP_PORT_SEG, seg);
}
ÒÔÉÏÊÇsmg.cÎļþÖеÄÄÚÈÝ¡£Ö÷ҪʵÏÖÁËÊýÂë¹ÜµÄÏÔʾ£¬²Ù×÷¡£

#include "includes.h"

//Init timer0 2.5ms
void Timer0Init(void)
{
TMOD |= 0x01;
TH0 = 0xec;
TL0 = 0x77;
TR0 = 1;
TF0 = 0;
EA = 1;
ET0 = 1;
}
void timer0() interrupt 1
{
    EA = 0;
TH0=0xec;
TL0=0x77;
    DispMuxHandler();
    EA = 1;
}
ÒÔÉÏÊÇtimer.cÎļþÖеijÌÐò¡£ÏµÍ³Ê¹Óö¨Ê±Æ÷0¶¨Ê±2.5ms¡£µ±Öжϵ½´ïʱÖжϷþÎñº¯Êýµ÷ÓÃDispMuxHandler()¡£ÔÚÕâ¸öº¯ÊýÖаÑÊýÂë¹ÜÏÖ´æÖеÄÄÚÈÝÈ«²¿ÏÔʾµ½ÊýÂë¹ÜÉÏ¡£Õâ¸öº¯ÊýÊ×ÏȹرÕËùÓеÄÊýÂë¹Ü£¬È»ºóÑ¡ÔñÒªÏÔʾµÄÊýÂë¹Ü£¬°ÑÒªÏÔʾµÄÊý¾ÝÏÔʾµ½¶ÔÓ¦µÄIO¿ÚÉÏ¡£ÎÒÃÇÓ¦ÓóÌÐòÖ»ÐèÒª¸Ä±äÏÖ´æÖеÄÄÚÈݾͿÉÒÔ°ÑÊý¾ÝÏÔʾµ½ÊýÂë¹ÜÉÏ¡£
¸ü¶àÏêÇé×Éѯ£º²ÜÀÏʦ QQ£º2859780203
                          À£ºTEL£º18948782707


º¯ÊýÃû³Æº¯Êý×÷ÓÃʹÓÃÕß
DispClrScrÇåÆÁÊýÂë¹ÜÓû§
DispInitÊýÂë¹ÜÏÔʾµÄ³õʼ»°Óû§£¬Éϵçºó±ØÐëµ÷ÓÃ1´Î
DispMuxHandler°ÑÊýÂë¹ÜÏÔ´æÖеÄÊý¾ÝÏÔʾµ½ÊýÂë¹ÜÉ϶¨Ê±Æ÷ÖжϷþÎñº¯Êý£¨Óû§²»Äܵ÷Óã©
DispStatClr¹Ø±Õijһ¸öÊýÂë¹ÜµÄÏÔʾDispMuxHandler
DispStatSet¿ªÆôijһ¸öÊýÂë¹ÜµÄÏÔʾDispMuxHandler
DispHexÔÚij¸öÊýÂë¹ÜÉÏÏÔʾʮÁù½øÖÆÊý¾ÝÓû§
DispPointÔÚij¸öÊýÂë¹ÜÉÏÏÔʾµãÓû§
DispInitPort³õʼ»¯ÊýÂë¹ÜÕ¼ÓõĶ˿ÚDispInit
DispOutDigÑ¡ÖÐijһλÊýÂë¹Ü¶¨Ê±Æ÷ÖжϷþÎñº¯Êý£¨Óû§²»Äܵ÷Óã©
DispOutSegÑ¡ÖÐijһ¶ÎÊýÂë¹Ü¶¨Ê±Æ÷ÖжϷþÎñº¯Êý£¨Óû§²»Äܵ÷Óã©
»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

ÄúÐèÒªµÇ¼ºó²Å¿ÉÒÔ»ØÌû µÇ¼ | Á¢¼´×¢²á

±¾°æ»ý·Ö¹æÔò

СºÚÎÝ|51ºÚµç×ÓÂÛ̳ |51ºÚµç×ÓÂÛ̳6Ⱥ QQ ¹ÜÀíÔ±QQ:125739409;¼¼Êõ½»Á÷QQȺ281945664

Powered by µ¥Æ¬»ú½Ì³ÌÍø

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí