Hallo, ich bin nun schon ewig im Internet mit Google etc. unterwegs und finde aber keine brauchbaren Howto´s in deutsch oder englisch, die einem den Einstieg in die Programmierung der STM32F Prozessoren mithilfe von Ride geben. Könnt ihr mir da welche Tipps geben ?
http://www.mikrocontroller.net/articles/MP32F103-Stick:_Ein_Mini-Mikrocontroller-Board_mit_USB_und_bis_zu_4MB_Datenspeicher unten auf der Seite gibt es ein paar links...
Hallo, danke für die schnelle Antwort. Ich habe hier das STM3210C-EVAL Board. Gibt es zu diesem evtl auch einstiegshilfen ?
Ich fürchte so einfach ist das nicht. Hier ist ein Anfang: http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/USER_MANUAL/CD00237044.pdf Sonst such mal nach deinem Board auf der st Seite. Dann musst Du dich durch die Beispiele durchschlagen. Es gibt auch ride7 Projektdateien zu einigen Beispielen in der Standard Library. Viel Glück!
Schon mal bei http://www.stm32circle.com versucht Fragen zu stellen? Der Schwerpunkt ist zwar auf einer anderen Hardware, naemlich von Raisonance, die auch das RIDE7 verkaufen aber da gibts viele Mitglieder die auch mal helfen. hth, Robert
Weißt Du, ich möchte es nur mal schaffen, einen einzigen Ausgang, an dem eine der 4 Leds angschlossen sind, zu initialisieren und zum Leuchten zu bringen. Mehr sollte das erste, selbstgeschriebene Programm nicht können. Habe es mittlerweile geschafft, die Demosoftware Beispiele von ST draufzuspielen und zu testen.
Ok, dass ich die LEDS zum leuchten bringen kann, eine nach der anderen habe ich mittlerweile geschafft. Jetzt möchte ich, dass ich eine einzelne LED mit dem Taster, der an PB9 hängt, ein und ausschalten kann. Wie geht man da sinnvollerweise vor. Habe mal den Taster so initialisiert:
1 | //Tasterinitialisierung
|
2 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; |
3 | //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
4 | //GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
|
5 | GPIO_Init(GPIOB, &GPIO_InitStructure); |
6 | //GPIO_Init(GPIOC, &GPIO_InitStructure);
|
7 | |
8 | // LED Ports definieren
|
9 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_7 | GPIO_Pin_13; |
10 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; |
11 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
12 | |
13 | GPIO_Init(GPIOD, &GPIO_InitStructure); |
14 | |
15 | while(1) |
16 | |
17 | {
|
18 | |
19 | if (ReadValue == 1) |
20 | |
21 | GPIO_SetBits(GPIOD, GPIO_Pin_7); //, GPIO_SetBits(GPIOD, GPIO_Pin_7) , GPIO_ResetBits(GPIOD, GPIO_Pin_7) , GPIO_ResetBits(GPIOD, GPIO_Pin_13); |
Ist dieser Ansatz zu gebrauchen, oder eher nicht ?
und noch:
1 | int ReadValue; |
2 | // Variable für bessere Übersicht festlegen
|
3 | ReadValue = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_9); |
hat oben noch gefehlt.
Annnnn Rrrrrrrrrrr schrieb: > if (ReadValue == 1) Da fehlt noch ein else Zweig mit dem Reset der GPIO, sonst bleiben die LED auch nach dem loslassen des Tasters an. Und die GPIO Takte der verwendeten Ports einschalten, sonst passiert gar nichts!
1 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); // GPIO A Takt freigeben |
2 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); // GPIO B Takt freigeben |
3 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); // GPIO C Takt freigeben |
4 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE); // GPIO D Takt freigeben |
5 | |
6 | // ... usw.
|
1 | void RCC_Configuration(void) |
2 | {
|
3 | // The maximum frequency of the AHB and the APB2 domains is 72 MHz
|
4 | // The maximum allowed frequency of the APB1 domain is 36 MHz
|
5 | |
6 | ErrorStatus HSEStartUpStatus; |
7 | |
8 | RCC_DeInit(); // RCC system reset(for debug purpose) |
9 | |
10 | |
11 | RCC_HSEConfig(RCC_HSE_ON); // Enable HSE |
12 | HSEStartUpStatus = RCC_WaitForHSEStartUp(); // Wait till HSE is ready |
13 | |
14 | if(HSEStartUpStatus == SUCCESS) |
15 | {
|
16 | FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); // Enable Prefetch Buffer |
17 | FLASH_SetLatency(FLASH_Latency_2); // Flash 2 wait state |
18 | RCC_HCLKConfig(RCC_SYSCLK_Div1); // HCLK = SYSCLK |
19 | RCC_PCLK2Config(RCC_HCLK_Div1); // PCLK2 = HCLK // ABP2 max 72 MHz !!! WICHTIG |
20 | RCC_PCLK1Config(RCC_HCLK_Div2); // PCLK1 = HCLK/2 // ABP1 max 36 MHz !!! WICHTIG |
21 | RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_3); // PLLCLK = 25MHz * 3 = 75 MHz !!! WICHTIG |
22 | RCC_PLLCmd(ENABLE); // Enable PLL |
23 | |
24 | while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET); // Wait till PLL is ready |
25 | |
26 | RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); // Select PLL as system clock source |
27 | |
28 | while(RCC_GetSYSCLKSource() != 0x08); // Wait till PLL is used as system clock source |
29 | }
|
30 | |
31 | |
32 | }
|
33 | |
34 | /* Configure all the GPIOA in Input Floating mode */
|
35 | GPIO_InitTypeDef GPIO_InitStructure; |
36 | |
37 | |
38 | |
39 | //RCC->APB2ENR |= RCC_APB2ENR_IOPBEN| RCC_APB2ENR_AFIOEN; // clock für PortB
|
40 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOB , ENABLE); |
scheint aber eingschalten zu sein der Takt, oder irre ich mich da ? Für Port D, sowohl als auch für Port B....
1 | while(1) |
2 | |
3 | {
|
4 | |
5 | if (ReadValue == 1) |
6 | |
7 | GPIO_SetBits(GPIOD, GPIO_Pin_7); |
8 | |
9 | else
|
10 | GPIO_ResetBits(GPIOD, GPIO_Pin_7); |
11 | }
|
Da der Taster 0 aktiv zu sein scheint, geht bei nichtbetätgtem Taster mal die LED an. mach ich bei READValue == 0 bleibt sie demzufolge aus. Aber wenn ich den Taster drücke oder loslasse, ändert sich halt immer noch nichts...
So gehts auch nicht, weil Du ReadValue = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_9); natürlich auch mit in die while Schleife nehmen musst!
1 | while(1) |
2 | |
3 | {
|
4 | int ReadValue; |
5 | // Variable für bessere Übersicht festlegen
|
6 | ReadValue = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_9); |
7 | |
8 | if (ReadValue == 1) |
9 | |
10 | GPIO_SetBits(GPIOD, GPIO_Pin_7);//, GPIO_ResetBits(GPIOD, GPIO_Pin_7);// , GPIO_ResetBits(GPIOD, GPIO_Pin_7) , GPIO_ResetBits(GPIOD, GPIO_Pin_13); |
11 | else
|
12 | GPIO_ResetBits(GPIOD, GPIO_Pin_7); |
geht irgendwie immer noch nicht.......
Ich denke jetzt ist es an der Zeit das Du mal die Debug Funktionen probierst. Im Einzelschritt mit Variablenanzeige siehst Du genau was passiert.
Zeig mal das ganze Programm. Bei den Kodeschnipseln blickt keiner mer durch.
das ist das Programm von einem Codebeispiel.......
1 | /* Includes ------------------------------------------------------------------*/
|
2 | #include "stm32f10x_conf.h" |
3 | #include <stdio.h> |
4 | #include <time.h> |
5 | |
6 | /** @addtogroup Template_Project
|
7 | * @{
|
8 | */
|
9 | |
10 | /* Private typedef -----------------------------------------------------------*/
|
11 | /* Private define ------------------------------------------------------------*/
|
12 | /* Private macro -------------------------------------------------------------*/
|
13 | /* Private variables ---------------------------------------------------------*/
|
14 | volatile unsigned short TimerVar; |
15 | |
16 | /* Private function prototypes -----------------------------------------------*/
|
17 | void NVIC_Configuration(void); |
18 | void RCC_Configuration(void); |
19 | void IO_Configuration(void); |
20 | |
21 | int ReadValue; |
22 | |
23 | /* Private functions ---------------------------------------------------------*/
|
24 | |
25 | /**
|
26 | * @brief Main program.
|
27 | * @param None
|
28 | * @retval None
|
29 | */
|
30 | int main(void) |
31 | {
|
32 | int x,anzahl; |
33 | anzahl = 40; |
34 | |
35 | RCC_Configuration(); // es muss richtige Definition in stm32f10x.h einkommentiert sein (STM32F10X_MD) |
36 | IO_Configuration (); |
37 | //NVIC_Configuration();
|
38 | |
39 | SysTick_Config(75000); // ruft in cyklischen Abständen eine ISR auf (1ms) |
40 | |
41 | // LED 3 und 4 leuchten immer
|
42 | |
43 | |
44 | /* Infinite loop
|
45 | while (1)
|
46 | {
|
47 |
|
48 | GPIO_ResetBits(GPIOD, GPIO_Pin_13);
|
49 | int start;
|
50 | start = GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_13);
|
51 | if (start == 1)
|
52 | {
|
53 | GPIO_SetBits(GPIOD, GPIO_Pin_13);
|
54 |
|
55 |
|
56 | }
|
57 |
|
58 | do {
|
59 | GPIO_SetBits(GPIOD, GPIO_Pin_3);
|
60 | }while(anzahl < 40);*/
|
61 | |
62 | //for (x=1;x=anzahl;x++)
|
63 | //for (x=1;x=anzahl;x++);
|
64 | /*GPIO_ResetBits(GPIOD, GPIO_Pin_3);
|
65 | GPIO_SetBits(GPIOD, GPIO_Pin_4);
|
66 | GPIO_SetBits(GPIOD, GPIO_Pin_3);
|
67 | GPIO_SetBits(GPIOD, GPIO_Pin_13);*/
|
68 | //warte(100);
|
69 | //GPIO_SetBits(GPIOD, GPIO_Pin_7);
|
70 | //GPIO_SetBits(GPIOD, GPIO_Pin_13);
|
71 | |
72 | |
73 | // Wenn Taster B3 nicht betätigt leuchtet LED4,
|
74 | // Reset von LED3 damit immer nur eine der beiden LEDs leuchtet
|
75 | |
76 | |
77 | |
78 | |
79 | // while(1)
|
80 | |
81 | //{
|
82 | |
83 | // Variable für bessere Übersicht festlegen
|
84 | ReadValue = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_9); |
85 | |
86 | if (ReadValue == 1) |
87 | |
88 | GPIO_SetBits(GPIOD, GPIO_Pin_7);//, GPIO_ResetBits(GPIOD, GPIO_Pin_7);// , GPIO_ResetBits(GPIOD, GPIO_Pin_7) , GPIO_ResetBits(GPIOD, GPIO_Pin_13); |
89 | else
|
90 | GPIO_ResetBits(GPIOD, GPIO_Pin_7); |
91 | //wait(100);
|
92 | /* if (ReadValue == 1)
|
93 | GPIO_ResetBits(GPIOD, GPIO_Pin_7);// , GPIO_SetBits(GPIOD, GPIO_Pin_3) , GPIO_ResetBits(GPIOD, GPIO_Pin_7) , GPIO_ResetBits(GPIOD, GPIO_Pin_13);
|
94 |
|
95 | if (ReadValue == 1)
|
96 | GPIO_ResetBits(GPIOD, GPIO_Pin_4) , GPIO_ResetBits(GPIOD, GPIO_Pin_3) , GPIO_SetBits(GPIOD, GPIO_Pin_7) , GPIO_ResetBits(GPIOD, GPIO_Pin_13);
|
97 | else GPIO_SetBits(GPIOD, GPIO_Pin_3) , GPIO_ResetBits(GPIOD, GPIO_Pin_4);
|
98 |
|
99 | if (ReadValue == 1)
|
100 |
|
101 | GPIO_SetBits(GPIOD, GPIO_Pin_7) , GPIO_ResetBits(GPIOD, GPIO_Pin_13);
|
102 |
|
103 | else GPIO_SetBits(GPIOD, GPIO_Pin_13) , GPIO_ResetBits(GPIOD, GPIO_Pin_7);
|
104 |
|
105 | */
|
106 | //}
|
107 | }
|
108 | |
109 | |
110 | |
111 | void NVIC_Configuration(void) |
112 | {
|
113 | NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); |
114 | }
|
115 | |
116 | void RCC_Configuration(void) |
117 | {
|
118 | // The maximum frequency of the AHB and the APB2 domains is 72 MHz
|
119 | // The maximum allowed frequency of the APB1 domain is 36 MHz
|
120 | |
121 | ErrorStatus HSEStartUpStatus; |
122 | |
123 | RCC_DeInit(); // RCC system reset(for debug purpose) |
124 | |
125 | |
126 | RCC_HSEConfig(RCC_HSE_ON); // Enable HSE |
127 | HSEStartUpStatus = RCC_WaitForHSEStartUp(); // Wait till HSE is ready |
128 | |
129 | if(HSEStartUpStatus == SUCCESS) |
130 | {
|
131 | FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); // Enable Prefetch Buffer |
132 | FLASH_SetLatency(FLASH_Latency_2); // Flash 2 wait state |
133 | RCC_HCLKConfig(RCC_SYSCLK_Div1); // HCLK = SYSCLK |
134 | RCC_PCLK2Config(RCC_HCLK_Div1); // PCLK2 = HCLK // ABP2 max 72 MHz !!! WICHTIG |
135 | RCC_PCLK1Config(RCC_HCLK_Div2); // PCLK1 = HCLK/2 // ABP1 max 36 MHz !!! WICHTIG |
136 | RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_3); // PLLCLK = 25MHz * 3 = 75 MHz !!! WICHTIG |
137 | RCC_PLLCmd(ENABLE); // Enable PLL |
138 | |
139 | while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET); // Wait till PLL is ready |
140 | |
141 | RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); // Select PLL as system clock source |
142 | |
143 | while(RCC_GetSYSCLKSource() != 0x08); // Wait till PLL is used as system clock source |
144 | }
|
145 | |
146 | |
147 | }
|
148 | |
149 | |
150 | void IO_Configuration(void) |
151 | {
|
152 | /* Configure all the GPIOA in Input Floating mode */
|
153 | GPIO_InitTypeDef GPIO_InitStructure; |
154 | |
155 | |
156 | |
157 | //RCC->APB2ENR |= RCC_APB2ENR_IOPBEN| RCC_APB2ENR_AFIOEN; // clock für PortB
|
158 | //RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOB , ENABLE);
|
159 | |
160 | |
161 | |
162 | // LED Ports definieren
|
163 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD , ENABLE); |
164 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_7 | GPIO_Pin_13; |
165 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
166 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
167 | |
168 | GPIO_Init(GPIOD, &GPIO_InitStructure); |
169 | |
170 | |
171 | //Tasterinitialisierung
|
172 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB , ENABLE); |
173 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; |
174 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; |
175 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; |
176 | GPIO_Init(GPIOB, &GPIO_InitStructure); |
177 | GPIO_Init(GPIOC, &GPIO_InitStructure); |
178 | |
179 | |
180 | |
181 | /*
|
182 | GPIOB->CRL &= ~(GPIO_CRL_MODE4 | GPIO_CRL_CNF4);
|
183 | GPIOB->CRL &= ~(GPIO_CRL_MODE5 | GPIO_CRL_CNF5);
|
184 | GPIOB->CRL &= ~(GPIO_CRL_MODE6 | GPIO_CRL_CNF6);
|
185 | GPIOB->CRL &= ~(GPIO_CRL_MODE7 | GPIO_CRL_CNF7);
|
186 | |
187 |
|
188 | GPIOB->CRL |= GPIO_CRL_MODE4
|
189 | | GPIO_CRL_MODE5
|
190 | | GPIO_CRL_MODE6
|
191 | | GPIO_CRL_MODE7;
|
192 | |
193 | AFIO->MAPR &= ~AFIO_MAPR_SWJ_CFG;
|
194 | AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_1;
|
195 | */
|
196 | |
197 | }
|
198 | |
199 | |
200 | |
201 | #ifdef USE_FULL_ASSERT
|
202 | |
203 | |
204 | void assert_failed(uint8_t* file, uint32_t line) |
205 | {
|
206 | /* User can add his own implementation to report the file name and line number,
|
207 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
208 | |
209 | /* Infinite loop */
|
210 | while (1) |
211 | {
|
212 | }
|
213 | }
|
214 | #endif
|
215 | |
216 | /**
|
217 | * @}
|
218 | */
|
Annnnn Rrrrrrrrrrr schrieb: > GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; > GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; > GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; Pin9? Oder doch eher Pin13?
Annnnn Rrrrrrrrrrr schrieb:
1 | > //RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOB , ENABLE); |
Der GPIO Takt fehlt, ist auskommentiert.
Annnnn Rrrrrrrrrrr schrieb: > Was bedeutet Floating ? Das würde nun doch etwas zu weit gehen. Siehe: http://www.mikrocontroller.net/articles/STM32F10x_Standard_Peripherals_Library Schau dir noch mal die Sache mit dem Pin13 genauer an...
oder mal ne ganz andere frage, vielleicht ist es besser, das projekt von grund auf neu zu schreiben. wenn ich in ride7 ein neues projekt erstelle ist mir schon klar, irgendwie muß ich dann noch eine neue source datei erstellen und zum schluss mit add item die main.c hinzufügen, oder ? aber wie schreibe ich die main.c ?
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.