{"id":1743,"date":"2023-05-06T08:57:23","date_gmt":"2023-05-06T08:57:23","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=1743"},"modified":"2023-05-06T08:57:26","modified_gmt":"2023-05-06T08:57:26","slug":"getting-started-with-stm32l053-spi-full-duplex","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=1743","title":{"rendered":"Getting started with STM32L053: SPI Full Duplex"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-1024x683.jpeg\" alt=\"\" class=\"wp-image-1744\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-1024x683.jpeg 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-300x200.jpeg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-768x512.jpeg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-1536x1024.jpeg 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-2048x1365.jpeg 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-1150x767.jpeg 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-750x500.jpeg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-400x267.jpeg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/AdobeStock_122425803-2-1-250x167.jpeg 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In the previous guide (<a rel=\"noreferrer noopener\" href=\"https:\/\/blog.embeddedexpert.io\/?p=1733\" data-type=\"URL\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=1733\" target=\"_blank\">here<\/a>), we saw how to transfer data over SPI using DMA. In this guide, we shall see how to receive data from SPI bus.<\/p>\n\n\n\n<p>In this guide, we shall cover the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>SPI Receive function.<\/li><li>MPU9250 connection.<\/li><li>Code.<\/li><li>Results.<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. SPI Receive function:<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p>In order to receive from SPI, the following steps are required:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Send dummy data (0x00 or 0xFF).<\/li><li>Wait until RX buffer is filled.<\/li><li>Read the DR register to store the received value.<\/li><\/ul>\n\n\n\n<p>Declare the following function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void spi1_receive(uint8_t *data,uint32_t size)<\/pre><\/div>\n\n\n\n<p>The function takes two arguments:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Pointer to the data to be received.<\/li><li>Size of data to be received.<\/li><\/ul>\n\n\n\n<p>Within the function:<\/p>\n\n\n\n<p>declare a while loop with condition of size:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">while(size)<\/pre><\/div>\n\n\n\n<p>within while loop:<\/p>\n\n\n\n<p>send dummy data:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">SPI1-&gt;DR = 0;  \/\/ send dummy data<\/pre><\/div>\n\n\n\n<p>Wait until the RX buffer is filled by reading RXNE bit in SR (Status Register) of the SPI:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"236\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-1024x236.png\" alt=\"\" class=\"wp-image-1745\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-1024x236.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-300x69.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-768x177.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-1536x353.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-2048x471.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-1150x265.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-750x173.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-400x92.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.42.54-AM-250x58.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">while (!((SPI1-&gt;SR) &amp;(SPi_SR_RXNE))){};<\/pre><\/div>\n\n\n\n<p>Store the data of DR register in the pointer and increment the pointer as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">*data++ = (SPI1-&gt;DR);<\/pre><\/div>\n\n\n\n<p>decrement the size:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">size--;<\/pre><\/div>\n\n\n\n<p>That all for the receive function:<\/p>\n\n\n\n<p>The entire function as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void spi1_receive(uint8_t *data,uint32_t size)\n{\n\twhile(size){\n\n\t\tSPI1-&gt;DR = 0;  \/\/ send dummy data\n\t\twhile (!((SPI1-&gt;SR) &amp;(1&lt;&lt;0))){};\n\t\t \/*Read data from Data Register*\/\n\t\t *data++ = (SPI1-&gt;DR);\n\t\tsize--;\n\n\t}\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. MPU9250 connection:<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"774\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1-1024x774.png\" alt=\"\" class=\"wp-image-1746\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1-1024x774.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1-300x227.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1-768x581.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1-1536x1161.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1-1150x869.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1-750x567.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1-400x302.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1-250x189.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screen-Shot-2022-01-17-at-6.39.56-AM-2048x1548-1.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>To initialize the MOU9250 acceleration part:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void MPU9250_beginAccel(uint8_t mode) {\n  switch(mode) {\n  case ACC_FULL_SCALE_2_G:\n    accelRange = 2.0;\n    break;\n  case ACC_FULL_SCALE_4_G:\n    accelRange = 4.0;\n    break;\n  case ACC_FULL_SCALE_8_G:\n    accelRange = 8.0;\n    break;\n  case ACC_FULL_SCALE_16_G:\n    accelRange = 16.0;\n    break;\n  default:\n    return; \/\/ Return without writing invalid mode\n  }\n\n  uint8_t data[2]={MPU9250_ADDR_ACCELCONFIG,mode};\n  cs_low();\n  spi_transmit(data, 2);\n  cs_high();\n\t\n}<\/pre><\/div>\n\n\n\n<p>To initialize the Gyroscope part:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">oid MPU9250_beginGyro(uint8_t mode) {\n  \n  switch (mode) {\n  case GYRO_FULL_SCALE_250_DPS:\n    gyroRange = 250.0;\n    break;\n  case GYRO_FULL_SCALE_500_DPS:\n    gyroRange = 500.0;\n    break;\n  case GYRO_FULL_SCALE_1000_DPS:\n    gyroRange = 1000.0;\n    break;\n  case GYRO_FULL_SCALE_2000_DPS:\n    gyroRange = 2000.0;\n    break;\n  default:\n    return; \/\/ Return without writing invalid mode\n  }\n  uint8_t data[2]={27,mode};\n  cs_low();\n  spi_transmit(data, 2);\n  cs_high();\n}\n<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>To read the acceleration:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">uint8_t MPU9250_accelUpdate(void)\n{\n\tuint8_t data=0x3B|READ_FLAG;\n\tcs_low();\n\tspi_transmit(&amp;data, 1);\n\tspi_receive(accelBuf,6);\n\tcs_high();\n\treturn 0;\n \n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>To read the gyroscope:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">uint8_t MPU9250_gyroUpdate(void)\n{\n\tuint8_t data=0x43|READ_FLAG;\n\tcs_low();\n\tspi_transmit(&amp;data, 1);\n\tspi_receive(gyroBuf, 6);\n\tcs_high();\n\treturn 0;\n}<\/pre><\/div>\n\n\n\n<p>For full details about MPU9250, refer to this guide <a href=\"https:\/\/blog.embeddedexpert.io\/?p=633\" data-type=\"URL\" data-id=\"https:\/\/blog.embeddedexpert.io\/?p=633\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p>In main.c:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#include &quot;spi.h&quot;\n#include &quot;stdio.h&quot;\n#include &quot;uart.h&quot;\n#include &quot;mpu9250.h&quot;\n#include &quot;delay.h&quot;\nint main(void)\n{\n\tsystick_init_ms(2097000);\n\tuart_init();\n\tspi_init();\n\tMPU9250_beginAccel(ACC_FULL_SCALE_16_G);\n\tMPU9250_beginGyro(GYRO_FULL_SCALE_2000_DPS);\n\n\twhile(1)\n\t{\n\t\tMPU9250_accelUpdate();\n\t\tMPU9250_gyroUpdate();\n\n\t\tprintf(&quot;Acceleration data %0.3f %0.3f %0.3f \\r\\n&quot;,MPU9250_accelX(),MPU9250_accelY(),MPU9250_accelZ());\n\t\tprintf(&quot;Gyroscope data %0.3f %0.3f %0.3f \\r\\n&quot;,MPU9250_gyroX(),MPU9250_gyroY(),MPU9250_gyroZ());\n\t\tdelay(500);\n\n\n\t}\n\n}\n<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">3. Code.<\/h2>\n\n\n\n<p>You may download the source code from here:<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/SPI_FullDuplex.zip\">SPI_FullDuplex<\/a><a href=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/SPI_FullDuplex.zip\" class=\"wp-block-file__button\" download>Download<\/a><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Results:<\/h2>\n\n\n\n<p>Upload the code to STM32L053 Nucleo-64 and open serial terminal and set baudrate to 115200 and you should get the following results:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"701\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.56.54-AM-1024x701.png\" alt=\"\" class=\"wp-image-1748\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.56.54-AM-1024x701.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.56.54-AM-300x205.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.56.54-AM-768x526.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.56.54-AM-1150x788.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.56.54-AM-750x514.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.56.54-AM-400x274.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.56.54-AM-250x171.png 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2023\/05\/Screenshot-2023-05-06-at-11.56.54-AM.png 1168w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Happy coding \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous guide (here), we saw how to transfer data over SPI using DMA. In this guide, we shall see how to receive data from SPI bus. In this guide, we shall cover the following: SPI Receive function. MPU9250 connection. Code. Results. 1. SPI Receive function: In order to receive from SPI, the following [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11,12],"tags":[],"class_list":["post-1743","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-peripheral-drivers","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/1743"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1743"}],"version-history":[{"count":1,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/1743\/revisions"}],"predecessor-version":[{"id":1749,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/1743\/revisions\/1749"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}