Skip to content
Snippets Groups Projects
Commit 20eab7f4 authored by Henrik Alsér's avatar Henrik Alsér
Browse files

Boot mode

parent ffd19f7c
Branches
No related tags found
No related merge requests found
# General lab info
In this course you will use Git extensively. To master Git and/or similar content management system with version control is absolutely essential engineering skill. If you have not used Git or similar, here is your chance to learn.
In this course you will use Git extensively. To master Git and/or similar content management system with version control is absolutely essential engineering skill. If you have not used Git or similar, here is your chance to learn.
If you are under Linux, you likely have Git installed by default (else use your Linux package manager to install it). If you are under Windows, then look at https://git-scm.com/downloads. If you get stuck, use the Telegram group to ask questions and help each other out.
......@@ -16,7 +16,7 @@ In general, to pass lab assignments you will:
- Submit links to the repos you have reviewed as a Canvas assignment.
- Attend the reviews/issues you have received
- Submit link to you final repo as a Canvas assignment.
Pay strict attention to the deadlines (the course depends on everyone being on time, to give and get reviews etc.). If you get sick and due to that cannot complete an assignment in time, give us a heads up in Telegram, and we will try to find a solution.
Remember to commit often, this allows you to rollback to previous states. Name your commits so that it reflects the recent changes, then your git log will make much more sense, and will be easier to navigate.
......@@ -25,34 +25,34 @@ Remember to commit often, this allows you to rollback to previous states. Name y
## Lab 1 (Schematics)
The main topic of this lab is to give you a good understanding on how to use the information in Datasheets to draw components and connect them in the schematic view. This lab should be done individually.
The main topic of this lab is to give you a good understanding on how to use the information in Datasheets to draw components and connect them in the schematic view. This lab should be done individually.
## Task 1
Read the whole lab instruction before you start.
Design and connect all necessary components to the microcontroller (MCU). Some of the components can’t be found in the standard libraries so you have to draw some of them by yourself and extract the necessary information through datasheets. The work flow of KiCad:
Design and connect all necessary components to the microcontroller (MCU). Some of the components can’t be found in the standard libraries so you have to draw some of them by yourself and extract the necessary information through datasheets. The work flow of KiCad:
- Add components and draw the schematic of your design
- Assign a footprint to your schematic components
- Generate a net-file
- Layout (Lab2)
### 1) Adding the microcontroller
Start ”KiCad” and follow the instructions:
- Make a new project.
- Open the schematic. (double-click on the *.sch-file)
- Click on Preferences/Manage symbols libraries.
- Open the schematic. (double-click on the \*.sch-file)
- Click on Preferences/Manage symbols libraries.
- Check the library `MCU_ST_STM32F4` is active in your project.
- Click on the ”Place symbol”-button to the right and then click on the sheet where you want the component to be placed.
- Click on the ”Place symbol”-button to the right and then click on the sheet where you want the component to be placed.
- Find your microcontroller (`STM32F411RETx`) in the stm32-library.
- You have now added the microcontroller to your project. It needs additional components to make it run, e.g. a crystal (for stable USB clocking), decoupling capacitors, power and a SWD (Serial Wire Debug) connector to program it.
- You have now added the microcontroller to your project. It needs additional components to make it run, e.g. a crystal (for stable USB clocking), decoupling capacitors, power and a SWD (Serial Wire Debug) connector to program it.
### 2) Decoupling Capacitors
To stabilize the voltage at the pins to the MCU, decoupling capacitors are used. When assigning decoupling capacitors for a microcontroller running at 50-100MHz, 100nF ceramic capacitors are usually suitable for each power-pin.
To stabilize the voltage at the pins to the MCU, decoupling capacitors are used. When assigning decoupling capacitors for a microcontroller running at 50-100MHz, 100nF ceramic capacitors are usually suitable for each power-pin.
However, this microcontroller needs additional decoupling capacitors for its internal voltage regulator and analog peripherals, you can find the datasheet by searching on internet (Hint: ”STM32F411 datasheet”).
......@@ -60,52 +60,52 @@ However, this microcontroller needs additional decoupling capacitors for its int
- Add capacitors to the power pins as the figure shows.
(Place component-button, click on sheet, device/C)
- Hoover over the capacitor, press ”V” and give the capacitor its value e.g.,100n.
- Connect them to the microcontroller using the ”wire” button. (W key)
- Connect them to the microcontroller using the ”wire” button. (W key)
You should have at least 8 capacitors connected to the microcontroller.
### 3) Adding supply symbols
VDD should be connected to +3.3V and VSS should be connected to ground. These nets are often used in a schematic, so to avoid drawing nets across the whole schematic you can add power ports. All power ports are global in your design, which means that all power ports of the same kind is connected to each other.
VDD should be connected to +3.3V and VSS should be connected to ground. These nets are often used in a schematic, so to avoid drawing nets across the whole schematic you can add power ports. All power ports are global in your design, which means that all power ports of the same kind is connected to each other.
- Click on the Place power port button.
- Select ”+3.3V”.
- Add power ports on appropriate places and connect them to the pins and capacitors that should have 3.3 volt.
- Do the same thing with GND.
- Note that the VCAP1 pin should NOT be connected to +3.3V.
### 4) NRST Reset pin
The NRST pin is an active low (0) input used to reset the MCU.
There is an internal pull-up resistor keeping the pin high (allowing the MCU to run). For more info on what a pull-up resistor is, search the internet for ”Pull-up resistor”.
There is an internal pull-up resistor keeping the pin high (allowing the MCU to run). For more info on what a pull-up resistor is, search the internet for ”Pull-up resistor”.
Later we will add a Reset Button, so that you can force reset even when the MCU is powered and running.
Later we will add a Reset Button, so that you can force reset even when the MCU is powered and running.
### 5) Pull-down resistor to BOOT0 (boot mode)
The microcontroller can boot in different modes, similar to how you can enter the BIOS when booting your PC by pressing the F2-key (or other F-key). This can save you in tricky situations, for example if you are playing with the main clock or with sleep modes and it crashes, making you unable to upload (flash) a new binary to the microcontroller. You can boot in "safe mode" by pulling this pin high (so it does not run you code on startup) allowing you to upload a new binary even if your code would otherwise brick your MCU.
The microcontroller can boot in different modes, similar to how you can enter the BIOS when booting your PC by pressing the F2-key (or other F-key). This can save you in tricky situations, for example if you are playing with the main clock or with sleep modes and it crashes, making you unable to upload (flash) a new binary to the microcontroller. You can boot in "safe mode" by pulling this pin high (so it does not run you code on startup) allowing you to upload a new binary even if your code would otherwise brick your MCU.
- Add a 10k pull-down resistor to the BOOT0 pin.
- Add a 2-pin header (*HA, var hittar de dessa i kickad enklast*) to BOOT0 and +3.3v, so that you can easily boot into "safe mode" by shorting the header using a "jumper".
- Add a "jumper" between BOOT0 and +3.3v, so that you can easily boot into "safe mode" by shorting these two terminals. You could make this a 3-pin header and "no-connect" the third terminal in order to provide a place to store the jumper when not in use.
### 6) Crystal
The crystal will resonate at a specified frequency. Its waveform will be used as an input to the PLL (Phase Locked Loop) that will multiply the crystal’s frequency. This is the crystal that will be used:https://www.elfa.se/en/quartz-hc49us-mhz-auris-000000m-hc49ussmd-f3030d20/p/17452820
The crystal will resonate at a specified frequency. Its waveform will be used as an input to the PLL (Phase Locked Loop) that will multiply the crystal’s frequency. This is the crystal that will be used:https://www.elfa.se/en/quartz-hc49us-mhz-auris-000000m-hc49ussmd-f3030d20/p/17452820
- Click on the Place component button.
- Find the device/Crystal.
- Place it close to `PH0` and `PH1`, pin 5 and 6 (`RCC_OS_CIN` and `RCC_OSC_OUT`).
- Connect the component with wires to the mentioned pins. Value 8.0MHz.
- Connect one 18p capacitor to each pin on the crystal and connect the other end of the capacitor to GND.
- Connect the component with wires to the mentioned pins. Value 8.0MHz.
- Connect one 18p capacitor to each pin on the crystal and connect the other end of the capacitor to GND.
### 7) Serial Wire Debug (SWD) connector
To program and debug the MCU we will use a SWD connector (6 pin header). Sometimes it can be tricky to find all the information in the datasheet and user manual for the microcontroller, all the information you need is there, it will just take time to find it. However, it can then be useful to follow proven examples like your Nucleo board. This is the connector that will be used:https://www.elfa.se/en/pin-header-6p-wuerth-elektronik-61300611121/p/30024526•Add one conn/CONN01X06 (male).
To program and debug the MCU we will use a SWD connector (6 pin header). Sometimes it can be tricky to find all the information in the datasheet and user manual for the microcontroller, all the information you need is there, it will just take time to find it. However, it can then be useful to follow proven examples like your Nucleo board. This is the connector that will be used:https://www.elfa.se/en/pin-header-6p-wuerth-elektronik-61300611121/p/30024526•Add one conn/CONN01X06 (male).
- Search for the Nucleo boards datasheet.
- In this datasheet search for the table that explains the connector `CN4` pinout. You can also investigate how they have connected the target MCUto these pins in the schematic below in the datasheet.
- You can connect pins without wires going everywhere. Use ”net labels”(button to the right) to name one wire. It will connect all wires with the same name in the local sheet.
- VDDTARGET→+3.3V. GND→GND. NRST→NRST. SWCLK→SWCLK (PA14). SWDIO→SWDIO (PA13). SWO→SWO (PB3)
- In this datasheet search for the table that explains the connector `CN4` pinout. You can also investigate how they have connected the target MCUto these pins in the schematic below in the datasheet.
- You can connect pins without wires going everywhere. Use ”net labels”(button to the right) to name one wire. It will connect all wires with the same name in the local sheet.
- VDDTARGET→+3.3V. GND→GND. NRST→NRST. SWCLK→SWCLK (PA14). SWDIO→SWDIO (PA13). SWO→SWO (PB3)
### 8) Power from USB
......@@ -116,7 +116,7 @@ One easy way to get power to your project is through USB. It can deliver up to 1
### 9) 3.3v Power Supply
The MCU needs a stable voltage. A common for digital components is 3.3v. To this end we will use a fixed LDO (low dropout) regulator, with a 5v input (powered from the USB connector) and 3.3v output. We will use the (*HA*)
The MCU needs a stable voltage. A common for digital components is 3.3v. To this end we will use a fixed LDO (low dropout) regulator, with a 5v input (powered from the USB connector) and 3.3v output. We will use the (_HA_)
Look in the datasheet for reference values for decoupling. Later we will design the power supply for the PWM3389 sensor, which is a bit trickier.
......@@ -124,25 +124,25 @@ Look in the datasheet for reference values for decoupling. Later we will design
Download the general [datasheet](https://www.pixart.com/products-detail/4/PMW3389DM-T3QU), and look at section 3. There you will find a reference schematic.
For some components (like the PMW3389DM-T3QU) there might not exist a pre-made library, so you will now learn how to draw your own component.
For some components (like the PMW3389DM-T3QU) there might not exist a pre-made library, so you will now learn how to draw your own component.
- Click on Tools/ Symbol Library Editor.
- Create a new library for your project and click on Create New symbol inthe new library).
- Component name ”PMW3389”. OK.
- Component name ”PMW3389”. OK.
- Add pins and name them according to the datasheet. Remember to assign the correct pin number as well.
- Make sure to set the ”Electrical type” on each pin according to usage (signal in/out, power in/out etc.) `X` marks a non connected pin. In our setting we don't use `GPO` so you can set it `X`.
- Save by clicking on the ”Save current component to new library”-button (found at the top). This is only done for the first component, you can add several components to the same lib later.
- Add the newly created component to your schematic.
Hint. Never, never ever, change the grid settings when placing the pins in the symbol.
### 11) 1.9v Power Supply
As you see in the PWM3389DM-T3QU datasheet and reference schematics, the sensor requires a 1.9v power supply. This is much less common voltage (try finding one from Elfa or rs-online) and you will likely fail.
To that end, you can use an adjustable regulator (*HA*).
To that end, you can use an adjustable regulator (_HA_).
The equation for the output voltage can be found in the datasheet for (*HA*).Hint: A good rule of thump is one 100nF ceramic capacitor to each power-pin. Hint2: The smoothing capacitor should be an electrolytic capacitor, hence polarized.
The equation for the output voltage can be found in the datasheet for (_HA_).Hint: A good rule of thump is one 100nF ceramic capacitor to each power-pin. Hint2: The smoothing capacitor should be an electrolytic capacitor, hence polarized.
Once you have added the 1.9v power supply you can add a new power net, and connect that to your PMW3389 component.
......@@ -152,7 +152,7 @@ Now add a reset button. Suitable value for capacitor is found in the MCU data sh
### 13) Power LEDs and probing pins
In order to see that your system is correctly powered, it is common to add both probing pins/pads and LEDs. You can use (*HA*) and a [led caluclator](https://ohmslawcalculator.com/led-resistor-calculator) to design suitable current limiter. Use values from the E12 series.
In order to see that your system is correctly powered, it is common to add both probing pins/pads and LEDs. You can use (_HA_) and a [led caluclator](https://ohmslawcalculator.com/led-resistor-calculator) to design suitable current limiter. Use values from the E12 series.
### 14) SPI
......@@ -160,13 +160,13 @@ SPI (Serial Peripheral Interface) is a common way to interconnect components syn
In order to allocate pins to peripherals there is a nice tool [STM32CubeMX](https://www.st.com/en/development-tools/stm32cubemx.html). Install STM32CubeMX (either using the link, or your package manager), select the target (smt32f401, e.g.) and find suitable (unused pins for) SPI communication. E.g., using SPI2 you can assign.
``` shell
```shell
// Configure SPI
// spi2
// sck - pb10,
// miso - pc2,
// mosi - pc3,
// ncs - pb4,
// sck - pb10,
// miso - pc2,
// mosi - pc3,
// ncs - pb4,
```
Decide on which pins you want to use, and connect the PMW3389 to your MCU. You can connect the `Motion` signal to a free GPIO (its used to generate an interrupt when the sensor detects a motion event, for allowing wake from sleep mode). Likely you don't need this but you can add it in any case.
......@@ -175,33 +175,33 @@ Decide on which pins you want to use, and connect the PMW3389 to your MCU. You c
Until now you have used the USB only to power the system, but you will need to add data lines +D/-D as well for communication. Check the data sheet for specifics.
You may also want to protect your system from ESD (Electrostatic discharge). To that end you may optionally add protection circuitry (*HA*).
You may also want to protect your system from ESD (Electrostatic discharge). To that end you may optionally add protection circuitry (_HA_).
### 16) Assign Footprint
It is very important that the pin numbering on your component is correct to the footprint in the library! Always double check with the datasheet. You will now associate each component to a footprint.
It is very important that the pin numbering on your component is correct to the footprint in the library! Always double check with the datasheet. You will now associate each component to a footprint.
- Annotate all the components, this will give your components a name.
- Click on the ”Assign PCB footprints to schematic symbols” to associate components and footprints”-button at the top.
- Click on the View selected footprint button at the top, it will display the footprint in question.
- We recommend you to use 0805-size capacitors and resistors. Associate all the res. and ceramic caps. to 0805 respectively, Handsoldering. (Ca-pacitorsSMD and ResistorsSMD)
- We recommend you to use 0805-size capacitors and resistors. Associate all the res. and ceramic caps. to 0805 respectively, Handsoldering. (Ca-pacitorsSMD and ResistorsSMD)
- The 10uF caps should have an electrolytic footprint. Search Elfa, rs-online first. If they don't have the components, check Farnellor digikey for appropriate size for the capacitor.
- Read in the datasheet or on the link for the voltage regulator and select the correct footprint. Make sure that all components are in stock for immediate delivery.
- Repeat for the crystal and SWD connector.
- MCU = HousingsQFP:LQFP-6410x10mmPitch0.5mm.
- USBOTG = Connect:USBMini-B (or to your liking)
- Don’t forget to save!
Hint: Check that the numbering of the pins are correct! Hint 2: When you are working with your project later, you will probably not find all footprints in the standard library. There are good tutorials on youtube on how to draw your ownfootprints.
Hint: Check that the numbering of the pins are correct! Hint 2: When you are working with your project later, you will probably not find all footprints in the standard library. There are good tutorials on youtube on how to draw your ownfootprints.
### 17) Electric Rule Check (ERC)
ERC is a check that detects if you have any ”lose ends”, meaning that it will give you a warning if you have a net with only one connection. It will also give you a warning if you have drawn a net to a component but the net and the component haven’t connected. To get the ERC to work as intended, you have to mark all the unused pins with a Not-connected flag, found to the right.
ERC is a check that detects if you have any ”lose ends”, meaning that it will give you a warning if you have a net with only one connection. It will also give you a warning if you have drawn a net to a component but the net and the component haven’t connected. To get the ERC to work as intended, you have to mark all the unused pins with a Not-connected flag, found to the right.
- 1) ”Perform electrical rules check” button (Ladybug button).
- 2) Do a ERC.
- 3) Fix errors.4.
- 4) Repeat point 1 until errors == 0 && warnings == 3. The GND net is not connected to a Power output, the 5 voltage neither and the capacitor connected to VCAP1 is not connected to a power output.
- 1. ”Perform electrical rules check” button (Ladybug button).
- 2. Do a ERC.
- 3. Fix errors.4.
- 4. Repeat point 1 until errors == 0 && warnings == 3. The GND net is not connected to a Power output, the 5 voltage neither and the capacitor connected to VCAP1 is not connected to a power output.
## First Submission
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment