1 Wire STM32

Jan Waclawek konfera na efton.sk
Úterý Červenec 23 11:41:07 CEST 2013


Naco inicializujete ten isty pin trikrat? Staci raz ako OD s pullupom.

wek


----- Original Message ---------------
>Peru se s 1 Wire sbìrnicí na STM32F0. Nìjak jsem se zamotal do nastavení GPIO pro vstup a pro výstup.
>
>Globální definice portu (pinu):
>RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
>GPIO_StructInit (&GPIO_InitStructure);
>GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
>GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
>GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
>GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
>GPIO_Init(GPIOA, &GPIO_InitStructure);
>
>Vystup - funkce ow_pin_out():
>GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
>GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
>GPIO_Init(GPIO_OW, &GPIO_InitStructure);
>
>Vstup - funkce ow_pin_in():
>GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
>GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
>GPIO_Init(GPIO_OW, &GPIO_InitStructure);
>
>Reset sbìrnice:
>ow_pin_out();
>GPIO_ResetBits(GPIOA, GPIO_Pin_3);	// uzemnit
>delay_us(600);
>GPIO_SetBits(GPIOA, GPIO_Pin_3);
>ow_pin_in();
>delay_us(150);
>out = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3);
>ow_pin_out();
>delay_us(400);
>return out;
>
>Je to tak správnì, nebo dìlám nìkde chybu? GPIO_OType_PP/OD si nìjak nejsem jistej. PullUp resistor fyzicky pøipojenej nemám, ten defunuji GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP.
>


Další informace o konferenci Hw-list