Presentation is loading. Please wait.

Presentation is loading. Please wait.

PRJ2: ESP2-UC workshop 1 Introductie 1.

Similar presentations


Presentation on theme: "PRJ2: ESP2-UC workshop 1 Introductie 1."— Presentation transcript:

1 PRJ2: ESP2-UC workshop 1 Introductie 1

2 Hoe dit onderdeel in elkaar zit Tooling GPIO
Leerdoelen vandaag Hoe dit onderdeel in elkaar zit Tooling GPIO 2

3 Overzicht semester Periode 3 en 4 EC’s
Embedded Systems Project 2: sensoren en actuatoren (ESP2) Project 2 10 Projectopdracht Projectvaardigheden workshop 32-bit Microcontroller workshop Information Technology 2 Electrical Engineering Fundamentals 2 3

4 Literatuur Han Scholar: ET-V12-ES 4

5 Aanschaffen: STM32F0DISCOVERY discovery development kit
Benodigde Materiaal Aanschaffen: STM32F0DISCOVERY discovery development kit Zie: ARLE = Applied Reseach Lab Engineering 5 5

6 praktische opdrachten
Werkwijze workshops praktische opdrachten 6

7 Toetsing Productrapport 25 % Product 25 % Productpresentatie √
Printontwerp √ Professional Skills √ Integrale toets % 7

8 Onderwerpen Installation and verification of the SDE & GPIO
Voorjaarsvakantie Ontwikkelweek Architecture of the STM32F051x & USART Standard Peripheral Driver Library Timers/Counters & PWM ADC/DAC I2C DMA 8

9 ST32F4 Pebble Time Smartwatch

10 Hoe dit onderdeel in elkaar zit Tooling GPIO
Vandaag Hoe dit onderdeel in elkaar zit Tooling GPIO 10

11 Documents STM32F05xxx Reference Manual ui/static/active/en/resource/technical/document/ref erence_manual/DM pdf STM32F051R8 Datasheet 9/SS1574/LN7/PF251901 11

12 MDK-ARM Microcontroller Development Kit
Tools MDK-ARM Microcontroller Development Kit Download vanaf: Installeer 12

13 Dit start automatisch de ‘Pack Installer’
Tools Dit start automatisch de ‘Pack Installer’ Installeer ten minste Keil::STM32F0xx_DFP 13

14 Tools Installeer de ST-LINK/V2 drivers vanaf: L1984/SC724/SS1677/PF251168 14

15 Example project Download example ZIP file from Scholar
Start μVision by double clicking the file blinky.uvprojx Build the project by pressing F7 or The Build Output should look like this: Connect the STM32F0-Discovery board to your PC/laptop. Program the microcontroller by pressing the load button or from the menu Flash -> Download

16 Example project Troubles during installation or running the blinky project? See Scholar for additional information. 2. Ask your teacher.

17 Hoe dit onderdeel in elkaar zit Tooling GPIO
Vandaag Hoe dit onderdeel in elkaar zit Tooling GPIO 17

18 General Purpose Input Output
GPIO General Purpose Input Output GPIOx-IDR 16-bits simultaneous GPIOx-MODER input, output, alternate function or analog GPIOx-PUPDR Pull-up, Pull-down, disabled GPIOx-ODR 16-bits simultaneous GPIOx-OTYPER Push-pull, open-drain or disabled GPIOx-BSRR Individual Bit Set Reset

19 GPIO registers

20 GPIO registers

21 stm32f0xx.h typedef struct {
__IO uint32_t MODER; /* port mode register */ __IO uint16_t OTYPER; /* port output type register */ uint16_t RESERVED0; __IO uint32_t OSPEEDR; /* port output speed register */ __IO uint32_t PUPDR; /* port pull-up/pull-down register */ __IO uint16_t IDR; /* port input data register */ uint16_t RESERVED1; __IO uint16_t ODR; /* port output data register */ uint16_t RESERVED2; __IO uint32_t BSRR; /* port bit set/reset registerBSRR */ __IO uint32_t LCKR; /* port configuration lock register */ __IO uint32_t AFR[2]; /* alternate function low register */ __IO uint16_t BRR; /* bit reset register */ uint16_t RESERVED3; } GPIO_TypeDef;

22 CMSIS Compliant ! Code – Register access //in stm32f0xx.h
#define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) //0x //in your code: GPIOC->ODR = 0x ; -> : “indirect selection operator” CMSIS Compliant !

23 Code - Set individual bits
#define RCC_AHBENR_GPIOCEN ((uint32_t)0x ) //set individual bit: RCC->AHBENR |= RCC_AHBENR_GPIOCEN; Register Mask register |= mask; ≡ register = register | mask; Individual set: bitwise or Example: Register 0b Mask 0b OR

24 Code – Clear individual bits
#define GPIO_OTYPER_OT_8 ((uint32_t)0x ) #define GPIO_OTYPER_OT_9 ((uint32_t)0x ) //clear individual bits: GPIOC->OTYPER &= ~(GPIO_OTYPER_OT_8 | GPIO_OTYPER_OT_9); Register Mask GPIO_OTYPER_OT_8 0b GPIO_OTYPER_OT_9 0b OR Mask 0b Individual clear: bitwise and with bitwise inverse Register 0b ~Mask 0b AND Register 0b

25 Code – Toggle individual bits
GPIOC->ODR ^= GPIO_ODR_0; Register Mask Individual toggle: bitwise xor Example: Register 0b Mask 0b XOR Register 0b

26 GPIO example #include "stm32f0xx.h" void delay(const int d);
int main(void) { RCC->AHBENR |= RCC_AHBENR_GPIOCEN; //GPIOC Periph clock enable GPIOC->MODER |= (GPIO_MODER_MODER8_0 | GPIO_MODER_MODER9_0); //PC8 and PC9 output GPIOC->OTYPER &= ~(GPIO_OTYPER_OT_8 | GPIO_OTYPER_OT_9); //Push pull mode selected   GPIOC->OSPEEDR |= (GPIO_OSPEEDER_OSPEEDR8 | GPIO_OSPEEDER_OSPEEDR9); //maximum speed GPIOC->PUPDR &= ~(GPIO_PUPDR_PUPDR8 | GPIO_PUPDR_PUPDR9); //no pull-up or pull-down while(1) GPIOC->BSRR = GPIO_BSRR_BS_9; // Set PC9 GPIOC->BSRR = GPIO_BSRR_BR_8; // Set PC8 delay(SystemCoreClock/8); // delay 1 sec. GPIOC->BSRR = GPIO_BSRR_BR_9; // Reset PC9 GPIOC->BSRR = GPIO_BSRR_BS_8; // Reset PC8 }

27 Assignment 1 Make the blue LED blink with ~ 2 Hz while the green LED blinks with ~10 Hz.

28 Assignment 2 So far we have seen how to use outputs. In a similar way inputs can be used. Adapt the project blinky.uvprojx so that: when the blue USER Push button is not pressed, the blue LED blinks with a frequency of ~ 1 Hz. when the blue USER Push button is pressed, the blue LED blinks with a frequency of ~ 10 Hz. Tips: The features of the STM32F0DISCOVERY board are described in the User Manual UM1525, which can be found on the STM32F0DISCOVERY website. In paragraph 4.9 is described which I/O pin is connected to the blue USER Push button. Remember to also enable this I/O pin’s peripheral clock!

29 Assignment 3 Use a breadboard and connect eight LED’s to PC0 to PC7.
Implement a LED chaser that changes direction when pressing the blue USER Push button.


Download ppt "PRJ2: ESP2-UC workshop 1 Introductie 1."

Similar presentations


Ads by Google