<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=4&amp;t=12636&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2015-08-14T20:53:35+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=12636&amp;mode</id>
<entry>
<author><name><![CDATA[QuadMan]]></name></author>
<updated>2015-08-14T20:53:35+01:00</updated>
<published>2015-08-14T20:53:35+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137321#p137321</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137321#p137321"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137321#p137321"><![CDATA[
Witam,<br /><br /><div class="quotetitle">xamrex napisał(a):</div><div class="quotecontent"><br />No ale nie mogę od razu wypełnić całej jeśli na danhm porcie (np. A) ustawiam piny jako wejścia  i wyjścia.<br />Wtedy muszę wypełnić ją dwa razy, tak ?<br /></div><br /><br />no niezupełnie, możesz to np. zrobić tak:<br /><br />[syntax=c]void GPIO_Configuration(void) {<br /><br /><br />GPIO_InitTypeDef GPIO_InitStructure;<br /><br />/* Config PORTs OUT */<br /><br />GPIO_InitStructure.GPIO_Pin = LCD_RS | KEY_ONE | FSEG | MOSFETA ;<br />GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;<br />GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_1;<br />GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<br />GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<br />GPIO_Init(GPIOA, &amp;GPIO_InitStructure);<br /><br /><br />/* Config LO_ACC Pin */<br /><br />GPIO_InitStructure.GPIO_Pin = LO_ACC ;<br />GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;<br />GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;<br />GPIO_Init(GPIOF, &amp;GPIO_InitStructure);<br /><br />}<br /><br /><br /><br /><br />int main( void)<br />{<br /><br /><br />GPIO_Configuration();<br /><br />while(1){<br /><br /><br /><br /><br />}<br /><br />}[/syntax]<br /><br />Wtedy nie masz struktury GPIO_InitStructure jako globalnej i po kolei ustawiasz używane porty.<br /><br />P.S. Nieprecyzyjnie się wyraziłem w poprzednim poście: Przed wywołaniem funkcji konfigurującej musisz wypełnić wszystkie pola struktury, a jeśli pól tejże struktury nie modyfikujesz, to przy kolejnych wywołaniach tej samej funkcji konfigurującej oczywiście już nie musisz. Domyślnie przyjąłem, że ta struktura jest zadeklarowana jako zmienna lokalna, stąd skrót myślowy, że musisz zawsze wypełniać wszystkie pola struktury. <br /><br />Pozdrawiam, QuadMan.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=5291">QuadMan</a> — 14 sie 2015, o 20:53</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2015-08-14T20:49:15+01:00</updated>
<published>2015-08-14T20:49:15+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137319#p137319</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137319#p137319"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137319#p137319"><![CDATA[
Mam teraz coś takiego:<br />[syntax=c]/* Includes ------------------------------------------------------------------*/<br />#include &quot;stm32f0xx.h&quot;<br />#include &quot;stm32f0xx_rcc.h&quot;<br />#include &quot;stm32f0xx_gpio.h&quot;<br /><br /><br /><br /> void GPIO_Init_Mode(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin, GPIOMode_TypeDef mode) {<br />       GPIO_InitTypeDef GPIO_InitStructure;<br />       GPIO_InitStructure.GPIO_Pin = GPIO_Pin;<br />       GPIO_InitStructure.GPIO_Mode = mode;<br />       GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;<br />       GPIO_InitStructure.GPIO_OType= GPIO_OType_PP;<br />       GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;<br /><br />       GPIO_Init(GPIOx, &amp;GPIO_InitStructure);<br /> }<br />void IOToggle(void) {<br /><br />uint32_t times;<br /><br /><br />RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);<br />RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);<br /><br /><br />GPIO_Init_Mode(GPIOC,GPIO_Pin_9,GPIO_Mode_OUT);<br />GPIO_Init_Mode(GPIOC,GPIO_Pin_8,GPIO_Mode_OUT);<br />GPIO_Init_Mode(GPIOA,GPIO_Pin_0,GPIO_Mode_IN);<br /><br />GPIO_WriteBit(GPIOC,GPIO_Pin_8,1);<br />GPIO_WriteBit(GPIOC,GPIO_Pin_9,1);<br /><br />while (1)<br />{/*<br /><br /> if ((GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0) == 1)){<br />GPIO_WriteBit(GPIOC,GPIO_Pin_8,1);<br />GPIO_WriteBit(GPIOC,GPIO_Pin_9,1);<br />}else{<br />GPIO_WriteBit(GPIOC,GPIO_Pin_8,0);<br />GPIO_WriteBit(GPIOC,GPIO_Pin_9,0);<br />}<br />*/<br /> }<br /> }[/syntax]<br />Wszystko działa elegancko <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";-)" title="Puszcza oko" /><br />Dzięki wielkie <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";-)" title="Puszcza oko" /><br />jutro biorę sie za rsa ;-D<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 14 sie 2015, o 20:49</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[PROTON]]></name></author>
<updated>2015-08-14T20:39:51+01:00</updated>
<published>2015-08-14T20:39:51+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137315#p137315</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137315#p137315"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137315#p137315"><![CDATA[
Musisz wypełnić wszystkie elementy struktury:<br /><br />[syntax=c]/** <br />  * @brief  GPIO Init structure definition<br />  */ <br />typedef struct<br />{<br />  uint32_t GPIO_Pin;              /*!&lt; Specifies the GPIO pins to be configured.<br />                                       This parameter can be any value of @ref GPIO_pins_define */<br /><br />  GPIOMode_TypeDef GPIO_Mode;     /*!&lt; Specifies the operating mode for the selected pins.<br />                                       This parameter can be a value of @ref GPIOMode_TypeDef */<br /><br />  GPIOSpeed_TypeDef GPIO_Speed;   /*!&lt; Specifies the speed for the selected pins.<br />                                       This parameter can be a value of @ref GPIOSpeed_TypeDef */<br /><br />  GPIOOType_TypeDef GPIO_OType;   /*!&lt; Specifies the operating output type for the selected pins.<br />                                       This parameter can be a value of @ref GPIOOType_TypeDef */<br /><br />  GPIOPuPd_TypeDef GPIO_PuPd;     /*!&lt; Specifies the operating Pull-up/Pull down for the selected pins.<br />                                       This parameter can be a value of @ref GPIOPuPd_TypeDef */<br />}GPIO_InitTypeDef;[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1315">PROTON</a> — 14 sie 2015, o 20:39</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2015-08-14T20:29:06+01:00</updated>
<published>2015-08-14T20:29:06+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137311#p137311</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137311#p137311"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137311#p137311"><![CDATA[
No ale nie mogę od razu wypełnić całej jeśli na danhm porcie (np. A) ustawiam piny jako wejścia  i wyjścia.<br />Wtedy muszę wypełnić ją dwa razy, tak ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 14 sie 2015, o 20:29</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[QuadMan]]></name></author>
<updated>2015-08-14T19:55:50+01:00</updated>
<published>2015-08-14T19:55:50+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137300#p137300</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137300#p137300"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137300#p137300"><![CDATA[
Witam,<br /><br /><div class="quotetitle">PROTON napisał(a):</div><div class="quotecontent"><br />Jak wypełniasz strukturę to wypełniaj ją całą.<br /></div><br /><br />kolega <strong>PROTON</strong> był szybszy <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":-)" title="Szczęśliwy" />. Przy korzystaniu ze STD Lib <strong>zawsze</strong> wypełniaj całą strukturę konfigurującą dane peryferium. Inaczej możesz się zdziwić i dłuugo szukać błedu. Z kolei deklaracja struktur od peryferiów jako zmiennych globalnych, to moim zdaniem, średni pomysł, bo bardzo często jest tak, że konfigurujesz dane preyferium raz w całym programie i już do tego więcej nie wracasz, a RAM pozostaje zajęty ( to nota bene, jeden z zarzutów przeciwników STD Libs ). <br /><br />Pozdrawiam, QuadMan.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=5291">QuadMan</a> — 14 sie 2015, o 19:55</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[PROTON]]></name></author>
<updated>2015-08-14T19:39:14+01:00</updated>
<published>2015-08-14T19:39:14+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137297#p137297</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137297#p137297"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137297#p137297"><![CDATA[
Jak wypełniasz strukturę to wypełniaj ją całą.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1315">PROTON</a> — 14 sie 2015, o 19:39</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2015-08-14T19:37:52+01:00</updated>
<published>2015-08-14T19:37:52+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137296#p137296</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137296#p137296"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137296#p137296"><![CDATA[
Okej już znazłem,<br />Musiałem wyrzucić z funkcji  [syntax=c]void GPIO_Init_Mode(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIOMode_TypeDef mode)[/syntax]<br />definicje [syntax=c]GPIO_InitTypeDef GPIO_InitStructure;[/syntax]<br />nad tą funkjcę (zrobić ją jako zmienna globalną)<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 14 sie 2015, o 19:37</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[PROTON]]></name></author>
<updated>2015-08-14T19:29:24+01:00</updated>
<published>2015-08-14T19:29:24+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137295#p137295</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137295#p137295"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137295#p137295"><![CDATA[
Nie wiem, ale powiem że przekombinowałeś, pisz normalnie kod wtedy się w nim będzie łatwo połapać, dam mój przykład pod NUCLEO.<br /><br />[syntax=c]GPIO_InitTypeDef GPIO_InitStructure;<br />USART_InitTypeDef USART_InitStructure;<br />USART_ClockInitTypeDef USART_ClockInitStructure;<br />NVIC_InitTypeDef NVIC_InitStructure;<br />EXTI_InitTypeDef EXTI_InitStructure;<br />TIM_TimeBaseInitTypeDef TIM_InitStructure;<br />TIM_ICInitTypeDef TIM_ICInitStructure;<br />TIM_OCInitTypeDef TIM_OCInitStructure;<br /><br />SysTick_Config(SystemCoreClock / 60000);<br /><br />RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);<br />RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);<br />RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);<br />RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);<br />RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);<br /><br />GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2);<br />GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2);<br /><br />USART_ClockStructInit(&amp;USART_ClockInitStructure);<br />USART_ClockInit(USART2, &amp;USART_ClockInitStructure);<br /><br />/* USART2 PINS */<br />GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;<br />GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;<br />GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<br />GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;<br />GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<br />GPIO_Init(GPIOA, &amp;GPIO_InitStructure);<br /><br />/* USART2 */<br />USART_InitStructure.USART_BaudRate = 230400; //115200;<br />USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;<br />USART_InitStructure.USART_Mode = USART_Mode_Tx;<br />USART_InitStructure.USART_Parity = USART_Parity_No;<br />USART_InitStructure.USART_StopBits = USART_StopBits_1;<br />USART_InitStructure.USART_WordLength = USART_WordLength_8b;<br />USART_Init(USART2, &amp;USART_InitStructure);<br />USART_Cmd(USART2, ENABLE);<br /><br />/* Dioda na płytce - PA5 */<br />GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;<br />GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;<br />GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<br />GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;<br />GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<br />GPIO_Init(GPIOA, &amp;GPIO_InitStructure);<br /><br />/* Dioda dodatkowa - PC8, PC0, PC1, PC2 */<br />GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_10 | GPIO_Pin_11;<br />GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;<br />GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<br />GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;<br />GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<br />GPIO_Init(GPIOC, &amp;GPIO_InitStructure);<br /><br />/* RC5 - PC9 */<br />GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;<br />GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;<br />GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<br />GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;<br />GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;<br />GPIO_Init(GPIOC, &amp;GPIO_InitStructure);<br /><br />/* NVIC */<br />NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);<br />NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;<br />NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;<br />NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;<br />NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;<br />NVIC_Init(&amp;NVIC_InitStructure);<br /><br />SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource9);<br /><br />/* EXTI */<br />EXTI_InitStructure.EXTI_Line = EXTI_Line9;<br />EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;<br />EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;<br />EXTI_InitStructure.EXTI_LineCmd = ENABLE;<br />EXTI_Init(&amp;EXTI_InitStructure);<br /><br />/* TIM2 */<br />TIM_InitStructure.TIM_Period = 65535;<br />TIM_InitStructure.TIM_CounterMode = TIM_CounterMode_Up;<br />TIM_InitStructure.TIM_ClockDivision = 0;<br />TIM_InitStructure.TIM_Prescaler = 64;<br />TIM_TimeBaseInit(TIM2, &amp;TIM_InitStructure);[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1315">PROTON</a> — 14 sie 2015, o 19:29</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2015-08-14T19:14:42+01:00</updated>
<published>2015-08-14T19:14:42+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137293#p137293</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137293#p137293"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137293#p137293"><![CDATA[
<strong> PROTON</strong><br />Dzięki za pomoc.<br />Mam jeszcze jedno pytanie.<br />Mam taki kod:<br />[syntax=c]/* Includes ------------------------------------------------------------------*/<br />#include &quot;stm32f0xx.h&quot;<br />#include &quot;stm32f0xx_rcc.h&quot;<br />#include &quot;stm32f0xx_gpio.h&quot;<br /><br /><br />void GPIO_Init_Mode(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIOMode_TypeDef mode) {<br />      GPIO_InitTypeDef GPIO_InitStructure;<br />      GPIO_InitStructure.GPIO_Pin = GPIO_Pin;<br />      GPIO_InitStructure.GPIO_Mode = mode;<br />      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;<br />      GPIO_Init(GPIOx, &amp;GPIO_InitStructure);<br />}<br /><br />void IOToggle(void) {<br /><br />uint32_t times;<br /><br /><br />RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);<br />RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);<br /><br /><br />GPIO_Init_Mode(GPIOC,GPIO_Pin_8,GPIO_Mode_OUT);<br />GPIO_Init_Mode(GPIOC,GPIO_Pin_9,GPIO_Mode_OUT);<br />GPIO_Init_Mode(GPIOA,GPIO_Pin_0,GPIO_Mode_IN);<br /><br /><br /><br />while (1)<br />{<br /><br /> if ((GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0) == 1)){<br />GPIO_WriteBit(GPIOC,GPIO_Pin_8,1);<br />GPIO_WriteBit(GPIOC,GPIO_Pin_9,1);<br />}else{<br />GPIO_WriteBit(GPIOC,GPIO_Pin_8,0);<br />GPIO_WriteBit(GPIOC,GPIO_Pin_9,0);<br />}<br /><br /> }<br /> }[/syntax]<br />I teraz wszystko działa tak jak powinno, Gdy nacisnę przycisk obie diody świecą, po puszczeniu przestają świecić.<br /><br />ale jesli zmienię linię 24 i 25 miejscami (czyli najpierw ustawię pin9, a potem8), to po naciśnięciu przycisku świeci się tylko dioda na PC8, <br />Dlaczego tak się dzieje?<br /><br /><strong>Bardzo Bardzo Liczę na odpowiedź <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";-)" title="Puszcza oko" /></strong><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 14 sie 2015, o 19:14</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[PROTON]]></name></author>
<updated>2015-08-14T18:40:22+01:00</updated>
<published>2015-08-14T18:40:22+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137290#p137290</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137290#p137290"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137290#p137290"><![CDATA[
<div class="quotetitle">xamrex napisał(a):</div><div class="quotecontent"><br />a co jeśli ktoś chciałby PIN8 jako wyjście a PIN9 jako wejście..<br /><br />Jak wtedy to skonfigurować?<br /></div><br /><br />[syntax=c]GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;<br />GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;<br />GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<br />GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;<br />GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<br />GPIO_Init(GPIOC, &amp;GPIO_InitStructure);<br />GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;<br />GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;<br />GPIO_Init(GPIOC, &amp;GPIO_InitStructure);[/syntax]<br /><br /><strong><span style="color: #808000">------------------------ [ Dodano po: 1 minucie ]</span></strong><br /><br /><div class="quotetitle">xamrex napisał(a):</div><div class="quotecontent"><br />I po co włącza się zegar <br />[syntax=c]/* GPIOC Periph clock enable */<br /><br />RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);[/syntax]<br />Zawsze należy go włączyć? Niezależnie czy port ustawiony jest jako wyjście albo wejście ?<br /></div><br /><br />Włączając zegar włącza się cały port, zawsze trzeba go włączyć na początku.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1315">PROTON</a> — 14 sie 2015, o 18:40</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2015-08-14T18:16:29+01:00</updated>
<published>2015-08-14T18:16:29+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137288#p137288</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137288#p137288"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137288#p137288"><![CDATA[
I po co włącza się zegar <br />[syntax=c]/* GPIOC Periph clock enable */<br /><br />RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);[/syntax]<br />Zawsze należy go włączyć? Niezależnie czy port ustawiony jest jako wyjście albo wejście ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 14 sie 2015, o 18:16</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2015-08-14T16:43:23+01:00</updated>
<published>2015-08-14T16:43:23+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137282#p137282</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137282#p137282"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137282#p137282"><![CDATA[
anshar dzięki wielkie. to jest to czego szukałem <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";-)" title="Puszcza oko" />))<br /><br /><strong><span style="color: #808000">------------------------ [ Dodano po: 2 minutach ]</span></strong><br /><br />Jeszcze gdyby ktoś tak na szybko pomógł<br />Jest taka inicjalizacja:[syntax=c]GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;<br />GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;<br />GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<br />GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;<br />GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<br />GPIO_Init(GPIOC, &amp;GPIO_InitStructure);[/syntax]<br /><br />a co jeśli ktoś chciałby PIN8 jako wyjście a PIN9 jako wejście..<br /><br />Jak wtedy to skonfigurować?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 14 sie 2015, o 16:43</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[anshar]]></name></author>
<updated>2015-08-14T15:36:52+01:00</updated>
<published>2015-08-14T15:36:52+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137272#p137272</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137272#p137272"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137272#p137272"><![CDATA[
Może Ci się przyda: <a href="http://www.sunduino.pl/wordpress/coide-czyli-migamy-dioda-w-nowym-srodowisku-f0-discovery/"  class="postlink">http://www.sunduino.pl/wordpress/coide-czyli-migamy-dioda-w-nowym-srodowisku-f0-discovery/</a><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=7157">anshar</a> — 14 sie 2015, o 15:36</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2015-08-14T15:35:07+01:00</updated>
<published>2015-08-14T15:35:07+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137271#p137271</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137271#p137271"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137271#p137271"><![CDATA[
Czyli powininem się 'stosować' do tego poradnika:<br /><!-- m --><a class="postlink" href="http://elektronika2014.blogspot.com/2013/12/konfiguracja-eclipse-i-arm.html#more" >http://elektronika2014.blogspot.com/201 ... .html#more</a><!-- m --><br />a nie do tego:<br /><!-- m --><a class="postlink" href="https://www.youtube.com/watch?v=nP6TR6NAZTQ" >https://www.youtube.com/watch?v=nP6TR6NAZTQ</a><!-- m --><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 14 sie 2015, o 15:35</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[RafPe]]></name></author>
<updated>2015-08-14T15:25:43+01:00</updated>
<published>2015-08-14T15:25:43+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137268#p137268</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137268#p137268"/>
<title type="html"><![CDATA[Re: STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137268#p137268"><![CDATA[
Ogolnie a patrzales za OpenSTM32 ? Wtedy piszesz sobie ladnie w Eclipse i nawet ladnie wgrywanie wsadu sobie tam ustawic <br /><br />A co do braku mozliwosci ustawienia tej struktury to musisz miec bodajze odpowiednie referencje ?! (tutaj bardziej doswiadcznei w ARMach moga sie wypowiedziec : ) )<br /><br /><br />Tutaj masz jak ja sobie to ustawilem w OpenSTM32<br /><br />[syntax=c]/**<br />  ******************************************************************************<br />  * @file    main.c<br />  * @author  Ac6<br />  * @version V1.0<br />  * @date    01-December-2013<br />  * @brief   Default main function.<br />  ******************************************************************************<br />*/<br /> <br /> <br />#include &quot;stm32f4xx.h&quot;<br />#include &quot;stm32f4_discovery.h&quot;<br />#include &quot;stm32f4xx_hal_gpio.h&quot;<br />#include &quot;stm32f4xx_hal_rcc.h&quot;<br />#include &quot;stm32f4xx_hal_usart.h&quot;<br />#include &quot;stdlib.h&quot;<br /> <br />int main(void)<br />{<br />    GPIO_InitTypeDef        GPIO_InitStructure;<br /> <br />    RCC-&gt;AHB1ENR |= RCC_AHB1ENR_GPIODEN;<br /> <br />    GPIO_InitStructure.Pin  = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;<br />    GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;<br />    GPIO_InitStructure.Pull = GPIO_NOPULL;<br />    GPIO_InitStructure.Speed = GPIO_SPEED_FAST;<br /> <br />    HAL_GPIO_Init(GPIOD, &amp;GPIO_InitStructure);<br /> <br />    HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_SET);<br />    HAL_GPIO_WritePin(GPIOD,GPIO_PIN_13,GPIO_PIN_SET);<br />    //HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_SET);<br />    HAL_GPIO_WritePin(GPIOD,GPIO_PIN_15,GPIO_PIN_SET);<br /> <br /> <br />    for(;;);<br /> <br /> <br /> <br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=4344">RafPe</a> — 14 sie 2015, o 15:25</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xamrex]]></name></author>
<updated>2015-08-14T14:57:16+01:00</updated>
<published>2015-08-14T14:57:16+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137264#p137264</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137264#p137264"/>
<title type="html"><![CDATA[STM32 - Początki programowania]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=12636&amp;p=137264#p137264"><![CDATA[
Witam<br />Mam taki zestaw startowy <!-- m --><a class="postlink" href="https://kamami.pl/stm32-discovery/189175-stm32f0discovery.html" >https://kamami.pl/stm32-discovery/18917 ... overy.html</a><!-- m --> i postanowiłem się za niego zabrac.<br />Dzięki obejrzeniu tego poradnika udało mi się pomigać diodami:<br /><!-- m --><a class="postlink" href="https://www.youtube.com/watch?v=nP6TR6NAZTQ" >https://www.youtube.com/watch?v=nP6TR6NAZTQ</a><!-- m --><br />[syntax=c]#include &quot;stm32f0xx.h&quot;<br />int main(void)<br />{<br />volatile unsigned int i=0;<br />RCC -&gt;AHBENR |= (1&lt;&lt;19);  //wlaczeni clk dla p ortu c<br />GPIOC-&gt;MODER |=(1&lt;&lt;16);   //ustawienie portc PIN* jako wysjcie<br />GPIOC-&gt;ODR|=(1&lt;&lt;8);<br /><br />    while(1)<br />    {<br />    for (i=0;i&lt;1000000;i++){<br />    GPIOC-&gt;ODR|=(1&lt;&lt;8);<br />    }<br />    for (i=0;i&lt;1000000;i++){<br />        GPIOC-&gt;ODR&amp;=~(1&lt;&lt;8);<br />    }<br />    }<br />}[/syntax]<br /><br />Znanazłem jednak inny kod:<br /><!-- m --><a class="postlink" href="http://elektronika2014.blogspot.com/2013/12/konfiguracja-eclipse-i-arm.html#more" >http://elektronika2014.blogspot.com/201 ... .html#more</a><!-- m --><br />Który wydaje mi się ładniejszy (nie trzeba pamiętać tych rejestrów itp)...<br />[syntax=c]#include &quot;stm32f0xx.h&quot;<br />#include &quot;stm32f0xx_conf.h&quot;<br /><br />#define BSRR_VAL        0x0300<br />GPIO_InitTypeDef        GPIO_InitStructure;<br /><br />int main(void)<br />{<br /><br />  /* GPIOC Periph clock enable */<br />  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);<br /><br />  /* Configure PC8 and PC9 in output pushpull mode */<br />  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;<br />  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;<br />  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;<br />  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;<br />  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;<br />  GPIO_Init(GPIOC, &amp;GPIO_InitStructure);<br /><br />  volatile uint32_t times;<br /><br />  while (1)<br />  {<br />    /* Set PC8 and PC9 */<br />    GPIOC-&gt;BSRR = BSRR_VAL;<br /><br />    for(times=0;times&lt;1000000;times++);<br /><br />    /* Reset PC8 and PC9 */<br />    GPIOC-&gt;BRR = BSRR_VAL;<br /><br />    for(times=0;times&lt;1000000;times++);<br />   <br />  }<br />}[/syntax]<br />Jednak, ja nie mogę w CooCoxie ustawić takiej strukturki:<br />[syntax=c]GPIO_InitTypeDef        GPIO_InitStructure;[/syntax]<br /><br />Chodzi mi o to, że chce nauczyć się programowania dobrze..<br />To jest chyba coś takiego jak w przypadku AVR taki kod, [syntax=c]DDRD=(1&lt;&lt;PD2); //to jest dobrze<br />DDRD=4; // tak też można ale nie jest to dobry sposób[/syntax]<br />Gdzie jest jakiś poradnik, który polecacie dot. porgramowania STM32F0<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=74">xamrex</a> — 14 sie 2015, o 14:57</p><hr />
]]></content>
</entry>
</feed>