在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 調試通過的AVR mega16 SPI雙機通訊例子

            調試通過的AVR mega16 SPI雙機通訊例子

            作者: 時間:2016-11-13 來源:網絡 收藏
            //ICC-AVR application builder : 2007-7-18 13:01:11

            // Target : M16
            // Crystal: 7.3728Mhz
            // 作者:古欣
            // AVR與虛擬儀器 [url]http://www.avrvi.com[/url]
            // 功能:SPI主機模式,循環(huán)發(fā)送從1~255

            #include
            #include

            void port_init(void)
            {
            PORTA = 0x00;
            DDRA = 0x00;
            PORTB = 0x00;
            DDRB = 0x00;
            PORTC = 0x00; //m103 output only
            DDRC = 0x00;
            PORTD = 0x00;
            DDRD = 0x00;
            }

            //SPI initialize
            // clock rate: 57599hz
            void spi_init(void)
            {
            PORTB |= (1<DDRB |= (1<SPCR = 0x73; //setup SPI
            SPSR = 0x00; //setup SPI
            }

            //call this routine to initialize all peripherals
            void init_devices(void)
            {
            //stop errant interrupts until set up
            CLI(); //disable all interrupts
            port_init();
            spi_init();

            MCUCR = 0x00;
            GICR = 0x00;
            TIMSK = 0x00; //timer interrupt sources
            SEI(); //re-enable interrupts
            //all peripherals are now initialized
            }

            void SPI_MasterTransmit(char cData)
            {
            PORTB &=~ (1<SPCR |= (1</* 啟動數(shù)據(jù)傳輸 */
            SPDR = cData;
            /* 等待傳輸結束 */
            while(!(SPSR & (1<;
            PORTB |= (1<}

            void Delay(void) //延時,沒有詳細計算
            {
            unsigned int i,j;
            for(i=1000;i>0;i--)
            {
            for(j=200;j>0;j--)
            ;
            }
            }

            void main(void)
            {
            unsigned char i=0;
            init_devices();
            while(1)
            {
            for(i=255;i>0;i--)
            {
            SPI_MasterTransmit(i);
            Delay();
            }
            }
            }

            本文引用地址:http://www.biyoush.com/article/201611/316523.htm

            //ICC-AVR application builder : 2007-7-18 12:56:10
            // Target : M16
            // Crystal: 7.3728Mhz
            // 作者:古欣
            // AVR與虛擬儀器 [url]http://www.avrvi.com[/url]
            // 功能:從機模式,中斷方式接收,并在LED上顯示

            #include
            #include

            void port_init(void)
            {
            PORTA = 0x00;
            DDRA = 0xFF;
            PORTB = 0x00;
            DDRB = 0x00;
            PORTC = 0x00; //m103 output only
            DDRC = 0x00;
            PORTD = 0x00;
            DDRD = 0x00;
            }

            //SPI initialize
            // clock rate: 57599hz
            void spi_init(void)
            {
            SPCR = 0xE3; //setup SPI
            SPSR = 0x00; //setup SPI
            }

            #pragma interrupt_handler spi_stc_isr:11
            void spi_stc_isr(void)
            {
            //byte in SPDR has been sent/received
            PORTA = SPDR;
            }

            //call this routine to initialize all peripherals
            void init_devices(void)
            {
            //stop errant interrupts until set up
            CLI(); //disable all interrupts
            port_init();
            spi_init();

            MCUCR = 0x00;
            GICR = 0x00;
            TIMSK = 0x00; //timer interrupt sources
            SEI(); //re-enable interrupts
            //all peripherals are now initialized
            }

            void main(void)
            {
            init_devices();
            DDRB|=(1<while(1)
            ;//等待中斷
            }



            關鍵詞: AVRmega16SPI雙機通

            評論


            技術專區(qū)

            關閉