|
實現(xiàn)一個或多個8位二進(jìn)制數(shù)的串行發(fā)送。要求把PA0作為串行數(shù)據(jù)輸出端,PA1作為時鐘脈沖,PB0作為使能端
附件:工程模板
0.png (64.8 KB, 下載次數(shù): 56)
下載附件
2017-4-14 21:06 上傳
主程序源碼:
- #include "stm32f10x.h"
- #include "delay.h"
- #include "sys.h"
- void GPIOconfig(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB,ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1; // ????
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; //????50MHz
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //????
- GPIO_Init(GPIOA, &GPIO_InitStructure); //???GPIOA
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; // ????
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; //????50MHz
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //????
- GPIO_Init(GPIOB, &GPIO_InitStructure); //???GPIOA
- }
- int main(void)
- {
- u8 data=0x85,i;
- GPIOconfig();
- delay_init();
- PBout(0)=1;
- for(i=0;i<8;i++)
- {
- PAout(1)=0;
- if((data&0x01)==0x01)
- PAout(0)=1;
- else
- PAout(0)=0;
- delay_ms(20);
- PAout(1)=1;
- delay_ms(20);
- data=data>>1;
- }
-
- }
復(fù)制代碼 下載:
串行通信.rar
(1.06 MB, 下載次數(shù): 18)
2017-4-14 15:00 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|
|