Cos'è ElectroYou | Login Iscriviti

ElectroYou - la comunità dei professionisti del mondo elettrico

STM32F4 e Keil

Raccolta di codici sorgenti

Moderatore: Foto UtentePaolino

0
voti

[1] STM32F4 e Keil

Messaggioda Foto Utentealle96 » 7 mar 2015, 19:17

Salve a tutti,
ho comprato da poco la scheda STM32F4-Discovery e sto cercando di programmarla ma ho varie domande...
1) come si chiama il linguaggio di programmazione? (MDK arm5, CMSIS..)
2)qualcuno riesce a passarmi nomi di libri,link o tutorial dove poter imparare questo nuovo linguaggio?

L'ambiente è keil uvison5 ed è già settato bene infatti copiando qualche esempio sono riuscito a farlo girare ma anche con il datasheet sotto non riesco a capire bene tutte le istruzioni. qualcuno riesce a darmi una mano? O_/

Grazie e scusate l'ignoranza
Avatar utente
Foto Utentealle96
15 4
 
Messaggi: 47
Iscritto il: 21 feb 2012, 16:21

1
voti

[2] Re: STM32F4 e Keil

Messaggioda Foto Utentesimo85 » 7 mar 2015, 19:23

CMISIS = Cortex Microcontroller Software Interface Standard

http://www.arm.com/products/processors/ ... andard.php

Vedi questo articolo che ho scritto tempo fa : http://www.electroyou.it/simo85/wiki/stm32f4xx-tutorial

Se hai dubbi chiedi.

O_/
Avatar utente
Foto Utentesimo85
30,9k 7 12 13
Disattivato su sua richiesta
 
Messaggi: 9927
Iscritto il: 30 ago 2010, 4:59

0
voti

[3] Re: STM32F4 e Keil

Messaggioda Foto UtenteTardoFreak » 7 mar 2015, 19:43

A me il Micro Vision 5 non piace.
Io continuo ad utilizzare la versione 4.(settanta e rotti).
"La follia sta nel fare sempre la stessa cosa aspettandosi risultati diversi".
"Parla soltanto quando sei sicuro che quello che dirai è più bello del silenzio".
Rispondere è cortesia, ma lasciare l'ultima parola ai cretini è arte.
Avatar utente
Foto UtenteTardoFreak
73,9k 8 12 13
-EY Legend-
-EY Legend-
 
Messaggi: 15754
Iscritto il: 16 dic 2009, 11:10
Località: Torino - 3° pianeta del Sistema Solare

0
voti

[4] Re: STM32F4 e Keil

Messaggioda Foto Utentealle96 » 7 mar 2015, 20:09

Guarda allora ne approfitto per farti un paio di domande sul tuo codice.
Allora questa prima istruzione come funziona?
Codice: Seleziona tutto
RCC->AHB1RSTR |= RCC_AHB1RSTR_GPIODRST;


Ho capito che facendo rcc->ahb1rstr seleziono il registro all'interno di RCC e poi nello specifico vado a lavorare su GPIODRST ma dov'è l'assegnazione a 1 per resettare le porte? e a cosa serve la seconda istruzione
Codice: Seleziona tutto
RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIODRST);


che è pressochè uguale se non per l'operatore?

Anche in questo caso
Codice: Seleziona tutto
GPIOD->MODER = GPIO_MODER_MODER15_0;


come diciamo che il pin D15 è output se non assegnamo il valore 01?

Scusa la sfilza di domande ma ci gioco da poco O_/
Avatar utente
Foto Utentealle96
15 4
 
Messaggi: 47
Iscritto il: 21 feb 2012, 16:21

1
voti

[5] Re: STM32F4 e Keil

Messaggioda Foto Utentesimo85 » 7 mar 2015, 20:43

Le istruzioni usano gli operatori logici orientate bit a bit (in inglese: bitwsie operation)

alle96 ha scritto:Allora questa prima istruzione come funziona?

All'interno del file stm32f4xx.h la dichiarazione della struct RCC è questa:

Codice: Seleziona tutto
typedef struct
{
  __IO uint32_t CR;            /*!< RCC clock control register,                                  Address offset: 0x00 */
  __IO uint32_t PLLCFGR;       /*!< RCC PLL configuration register,                              Address offset: 0x04 */
  __IO uint32_t CFGR;          /*!< RCC clock configuration register,                            Address offset: 0x08 */
  __IO uint32_t CIR;           /*!< RCC clock interrupt register,                                Address offset: 0x0C */
  __IO uint32_t AHB1RSTR;      /*!< RCC AHB1 peripheral reset register,                          Address offset: 0x10 */
  __IO uint32_t AHB2RSTR;      /*!< RCC AHB2 peripheral reset register,                          Address offset: 0x14 */
  __IO uint32_t AHB3RSTR;      /*!< RCC AHB3 peripheral reset register,                          Address offset: 0x18 */
  uint32_t      RESERVED0;     /*!< Reserved, 0x1C                                                                    */
  __IO uint32_t APB1RSTR;      /*!< RCC APB1 peripheral reset register,                          Address offset: 0x20 */
  __IO uint32_t APB2RSTR;      /*!< RCC APB2 peripheral reset register,                          Address offset: 0x24 */
  uint32_t      RESERVED1[2];  /*!< Reserved, 0x28-0x2C                                                               */
  __IO uint32_t AHB1ENR;       /*!< RCC AHB1 peripheral clock register,                          Address offset: 0x30 */
  __IO uint32_t AHB2ENR;       /*!< RCC AHB2 peripheral clock register,                          Address offset: 0x34 */
  __IO uint32_t AHB3ENR;       /*!< RCC AHB3 peripheral clock register,                          Address offset: 0x38 */
  uint32_t      RESERVED2;     /*!< Reserved, 0x3C                                                                    */
  __IO uint32_t APB1ENR;       /*!< RCC APB1 peripheral clock enable register,                   Address offset: 0x40 */
  __IO uint32_t APB2ENR;       /*!< RCC APB2 peripheral clock enable register,                   Address offset: 0x44 */
  uint32_t      RESERVED3[2];  /*!< Reserved, 0x48-0x4C                                                               */
  __IO uint32_t AHB1LPENR;     /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */
  __IO uint32_t AHB2LPENR;     /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */
  __IO uint32_t AHB3LPENR;     /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */
  uint32_t      RESERVED4;     /*!< Reserved, 0x5C                                                                    */
  __IO uint32_t APB1LPENR;     /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */
  __IO uint32_t APB2LPENR;     /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */
  uint32_t      RESERVED5[2];  /*!< Reserved, 0x68-0x6C                                                               */
  __IO uint32_t BDCR;          /*!< RCC Backup domain control register,                          Address offset: 0x70 */
  __IO uint32_t CSR;           /*!< RCC clock control & status register,                         Address offset: 0x74 */
  uint32_t      RESERVED6[2];  /*!< Reserved, 0x78-0x7C                                                               */
  __IO uint32_t SSCGR;         /*!< RCC spread spectrum clock generation register,               Address offset: 0x80 */
  __IO uint32_t PLLI2SCFGR;    /*!< RCC PLLI2S configuration register,                           Address offset: 0x84 */
} RCC_TypeDef;


Da cui si vede la dichiarazione di AHB1RSTR

Codice: Seleziona tutto
  __IO uint32_t AHB1RSTR;      /*!< RCC AHB1 peripheral reset register,


RCC_AHB1RSTR_GPIODRST è una macro dichiarata alla linea 4848 dell' header in questione per il reset del GPIOD:

Codice: Seleziona tutto
#define  RCC_AHB1RSTR_GPIODRST               ((uint32_t)0x00000008)


Ora, compara il valore della dichiarazione di questa macro con quanto scritto a pag. 169 e 170 del datasheet. ;-)

alle96 ha scritto:e a cosa serve la seconda istruzione

A settare il registro tutto a 0. Mi piace usare le operazioni bit a bit. :D

alle96 ha scritto:come diciamo che il pin D15 è output se non assegnamo il valore 01?

Osserva bene le macro. Ti allego il file stm32f4xx.h.

stm32f4xx.zip
(55.38 KiB) Scaricato 226 volte
Avatar utente
Foto Utentesimo85
30,9k 7 12 13
Disattivato su sua richiesta
 
Messaggi: 9927
Iscritto il: 30 ago 2010, 4:59

1
voti

[6] Re: STM32F4 e Keil

Messaggioda Foto Utentealle96 » 7 mar 2015, 21:08

Ok, grazie alle macro ho capito mooolte più cose :lol: ma mi resta 1 un dubbio.
Se scrivo
Codice: Seleziona tutto
RCC->AHB1RSTR |= RCC_AHB1RSTR_GPIODRST;

chiedo di resettare il GPIOD, poi aggiungo
Codice: Seleziona tutto
RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIODRST);

per mettere l'intero registro a 0. Ma questo è stato fatto più per sicurezza che utilità? cioè funziona bene anche se non azzero il registro o devo azzerarlo altrimenti continuerebbe ad azzerare il GPIOD? O_/
Avatar utente
Foto Utentealle96
15 4
 
Messaggi: 47
Iscritto il: 21 feb 2012, 16:21

1
voti

[7] Re: STM32F4 e Keil

Messaggioda Foto Utentesimo85 » 7 mar 2015, 21:12

alle96 ha scritto:Ma questo è stato fatto più per sicurezza che utilità? cioè funziona bene anche se non azzero il registro o devo azzerarlo altrimenti continuerebbe ad azzerare il GPIOD?


Bit a 1 → RESET
Bit a 0 → NO RESET

Pag. 170 del datasheet. Benvenuto fra gli ARMers. :-)
Avatar utente
Foto Utentesimo85
30,9k 7 12 13
Disattivato su sua richiesta
 
Messaggi: 9927
Iscritto il: 30 ago 2010, 4:59

1
voti

[8] Re: STM32F4 e Keil

Messaggioda Foto UtenteTardoFreak » 7 mar 2015, 23:15

E mo' so caxxi da hahare! :mrgreen: :mrgreen: :mrgreen:
"La follia sta nel fare sempre la stessa cosa aspettandosi risultati diversi".
"Parla soltanto quando sei sicuro che quello che dirai è più bello del silenzio".
Rispondere è cortesia, ma lasciare l'ultima parola ai cretini è arte.
Avatar utente
Foto UtenteTardoFreak
73,9k 8 12 13
-EY Legend-
-EY Legend-
 
Messaggi: 15754
Iscritto il: 16 dic 2009, 11:10
Località: Torino - 3° pianeta del Sistema Solare


Torna a Firmware e programmazione

Chi c’è in linea

Visitano il forum: Nessuno e 5 ospiti