打印

想要多少个跑马灯?用74hc595来扩展输出口

[复制链接]
2357|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jessicazhou|  楼主 | 2011-10-21 11:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
先用两片扩出16个输出,不够还可以再增加


grace生成的USI初始化,还用翻译么?

/*
*  ======== USI_init ========
*  Initialize Universal Serial Interface
*/
void USI_init(void)
{
    /* Disable USI */
    USICTL0 |= USISWRST;
   
    /*
     * USI Control Register 0
     *
     * ~USIPE7 -- USI function disabled
     * USIPE6 -- USI function enabled
     * USIPE5 -- USI function enabled
     * ~USILSB -- MSB first
     * USIMST -- Master mode
     * ~USIGE -- Output latch enable depends on shift clock
     * USIOE -- Output enabled
     * USISWRST -- USI logic held in reset state
     *
     * Note: ~<BIT> indicates that <BIT> has value zero
     */
    USICTL0 = USIPE6 + USIPE5 + USIMST + USIOE + USISWRST;
   
    /*
     * USI Control Register 1
     *
     * USICKPH -- Data is captured on the first SCLK edge and changed on the following edge
     * ~USII2C -- I2C mode disabled
     * ~USISTTIE -- Interrupt on START condition disabled
     * ~USIIE -- Interrupt disabled
     * ~USIAL -- No arbitration lost condition
     * ~USISTP -- No STOP condition received
     * ~USISTTIFG -- No START condition received. No interrupt pending
     * USIIFG -- Interrupt pending
     *
     * Note: ~<BIT> indicates that <BIT> has value zero
     */
    USICTL1 = USICKPH + USIIFG;
   
    /*
     * USI Clock Control Register
     *
     * USIDIV_0 -- Divide by 1
     * USISSEL_2 -- SMCLK
     * ~USICKPL -- Inactive state is low
     * ~USISWCLK -- Input clock is low
     *
     * Note: ~<BIT> indicates that <BIT> has value zero
     */
    USICKCTL = USIDIV_0 + USISSEL_2;
   
    /*
     * USI Bit Counter Register
     *
     * ~USISCLREL -- SCL line is held low if USIIFG is set
     * USI16B -- 16-bit shift register mode. Both high and low byte registers USISRL
and USISRH are used. USISR addresses all 16 bits simultaneously
     * ~USIIFGCC -- USIIFG automatically cleared on USICNTx update
     * ~USICNT4 -- USI bit count
     * ~USICNT3 -- USI bit count
     * ~USICNT2 -- USI bit count
     * ~USICNT1 -- USI bit count
     * ~USICNT0 -- USI bit count
     *
     * Note: ~<BIT> indicates that <BIT> has value zero
     */
    USICNT = USI16B;
   
    /* Enable USI */
    USICTL0 &= ~USISWRST;
}

相关帖子

沙发
高亮登录| | 2011-10-22 18:04 | 只看该作者
这跟你说的芯片有啥关系

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

41

帖子

0

粉丝