Orodha ya maudhui:

Oscilloscope nne ndogo: Hatua 6
Oscilloscope nne ndogo: Hatua 6

Video: Oscilloscope nne ndogo: Hatua 6

Video: Oscilloscope nne ndogo: Hatua 6
Video: ГРЕНДПА и Гренни В РЕАЛЬНОЙ ЖИЗНИ! Почему они перепутали мой дом? GRANDPA GRANNY Chapter Two 2024, Novemba
Anonim
Oscilloscope nne ndogo
Oscilloscope nne ndogo

Ni mradi wa kufurahisha tu kuona ni kwa kasi gani ninaweza kushinikiza onyesho la matrix ya MAX7219. Na badala ya kuiendesha "mchezo wa maisha", niliamua kutengeneza "wigo" nayo. Kama utakavyoelewa kutoka kwa kichwa, hii sio mbadala wa oscilloscope halisi:-).

Kwa kuwa sina mpango wa kutumia hii kwa njia yoyote mbaya, sitafanya bodi ya mzunguko iliyochapishwa kwa hiyo. Labda, labda tu nitaiweka kwenye bodi ya manukato lakini kwa sasa iko, na nitakaa, kwenye ubao wa mkate. Pia hakuna kipaza sauti / kiambatisho cha kuingiza, lazima utoe ishara kati ya 0 na 3.3V, usiende hasi au zaidi ya 3.3V kwani unaweza kuharibu microcontroller.

Hatua ya 1: Vifaa

Vifaa
Vifaa
Vifaa
Vifaa
Vifaa
Vifaa

Ni ya bei rahisi, ya bei rahisi sana unaponunua sehemu huko China kupitia ebay au tovuti kama hizo. Inatumia bodi ya maendeleo ya STM32F103C8, wakati mwingine inaitwa "kidonge cha hudhurungi" ambacho nilinunua kwa karibu 2 euro (au USD, zina thamani sawa, mwisho wa 2018), maonyesho mawili ya 8x8x4 dot-matrix na chips MAX7219 juu yake, iliyonunuliwa kwa 5 euro kipande na encoder ya kuzunguka ya karibu 1 euro.

Inahitajika bila shaka ni usambazaji wa umeme unaoleta 3.3V kwa milliamps mia chache. Mdhibiti wa voltage kwenye bodi ya maendeleo ya STM32F103C8 haitumiki, haiwezi kutoa sasa ya kutosha kwa maonyesho. Jedwali la MAX7219 linabainisha voltage ya usambazaji inapaswa kuwa kati ya 4.0 na 5.5V lakini inaendesha vizuri kwa 3.3V, labda sio wakati unaitumia katika mazingira ya moto sana au baridi, lakini saa 20 Celsius ni sawa. Na sasa sio lazima nitumie waongofu wa kiwango kati ya mdhibiti mdogo na bodi za maonyesho.

Hatua ya 2: Jenga

Jenga
Jenga
Jenga
Jenga
Jenga
Jenga

Unapoangalia picha unaweza kuona kuwa ninatumia laini za umeme kwenye ubao wa mkate kwa njia isiyo ya kawaida, mistari yote juu ni reli nzuri na zote chini ni reli ya ardhini. Ni njia ambayo nimeitumia kuifanya na inafanya kazi vizuri, inafanya usanidi uonekane zaidi kama skimu ninayochora. Pia, nimeunda bodi ndogo ndogo zilizo na sehemu ambazo ninaweza kuziba kwenye ubao wa mkate ili kuharakisha vitu na zote zimesanidiwa kutumia laini mbili za juu kama chanya na mistari ya chini kama ardhi. Kama nilivyosema, azimio ni 4 bit (viwango 16), na kama kuna viongoz 4x8 karibu na kila mmoja kuna alama 32 tu za sampuli. Linganisha hiyo na Rigol Rigol DS1054Z (8 bit na 12Mpts) na utaona kuwa hii sio toy. Je! Bandwidth halisi ni nini, sijui, nimeijaribu hadi 10kHz na hiyo inafanya kazi vizuri.

Hatua ya 3: Programu

Programu
Programu
Programu
Programu
Programu
Programu
Programu
Programu

IDE ninayotumia ni Atollic TrueStudio ambayo mwanzoni mwa mwaka huu (2018) ilipitishwa na ST Micro Electronics na inapatikana bure, hakuna kikomo cha wakati, hakuna kikomo cha saizi ya nambari, hakuna skrini za nag. Pamoja nayo, ninatumia STM32CubeMX, programu ambayo inanipa nambari ya kuanzia na inazindua uanzishaji wa vifaa vyote. Na ina onyesho la pini zote za mdhibiti mdogo na matumizi yake. Hata ikiwa hautumii STM32CubeMX kutengeneza kificho, hii ni rahisi sana. Jambo moja ambalo sipendi ni ile inayoitwa HAL ambayo ni chaguo-msingi ya STM32CubeMX. Ninapendelea njia ya LowLayer ya kufanya kazi.

Kupanga microcontroller ninatumia programu ya ST-Link / debugger kutoka ST Micro Electronics au J-Link iliyotengenezwa na Segger. Vifaa hivi vyote sio bure, ingawa unaweza kununua nakala za Wachina kwa euro chache.

Hatua ya 4: Kuhusu Kanuni

Anwani ya MAX7219 ya LEDs kwa kile ninachokiita mtindo wa usawa, 8 inaongoza karibu na kila mmoja. Kwa oscilloscope 8 LED juu ya kila mmoja ingekuwa rahisi, kwa hivyo nilifanya bafa-rahisi ambayo imeandikwa na data kwa njia ya wima, na kusoma kwa njia ya usawa inayohitajika. MAX7219 hutumia nambari ya 16bit kwa LED 8, ambapo baiti ya kwanza hutumiwa kushughulikia laini iliyochaguliwa. Na kwa kuwa kuna moduli nne kati ya hizi, na pembejeo zao zimeunganishwa na matokeo ya moduli kabla yake, lazima utume hizo 16bits mara nne kufikia moduli ya mwisho. (Natumai ninafanya mambo wazi…) Takwimu zinatumwa kwa MAX7219 kwa kutumia SPI, itifaki rahisi lakini ya haraka sana. Hii ndio nilikuwa najaribu, ni kwa haraka gani unaweza kutuma data kwa MAX7219. Mwishowe, nilibadilisha kurudi kwa 9 MHz chini ya kasi ya kiwango cha juu cha data.

Ninatumia vipima viwili kati ya vinne vinavyopatikana vya STM32F103C8, moja kwa kizazi cha muda wa muda na nyingine kwa kusoma kisimbuzi cha rotary, ambacho huweka wakati. TIMER3 hutengeneza wakati wa wakati, inafanya kwa kugawanya saa na 230, kusasisha kaunta kila 3.2 uS. Mchawi encoder ya rotary unaweza kuchagua kuwa na hesabu ya kaunta kutoka kwa saa 2 za kunde hadi 2000 za kunde za saa. Wacha tuseme unachagua 100. TIMER3 kisha inazalisha TUKIO kila 320 uS. TUKIO hili husababisha ADC kurekodi sampuli ya ishara ya kuingiza, na kama ilivyo sampuli 32 za kuchukua kwa uchunguzi mmoja, hii itakamilika baada ya aprox. 10 mS. Katika 10mS unaweza kutoshea wavelength moja ya 100 Hz, au mbili ya 200 Hz, na kadhalika. Kupita juu ya mawimbi 3 kwa kila skrini hufanya iwe ngumu kutambua muundo wa wimbi ingawa.

Kwa wengine, ninaweza kukuelekeza kwa nambari, sio ngumu kufuata hata ikiwa una uzoefu tu na Arduino. Kwa kweli, unaweza kufanya kitu kimoja na Arduino, ingawa nina shaka kuwa ingefanya kazi haraka "kidonge cha bluu". STM32F103C8 ni microcontroller 32bit inayoendesha kwa 72 MHz, ina vifaa viwili vya SPI na ADC haraka sana.

Hatua ya 5: Kuu

#ifndef _MAIN_H _ # fafanua _MAIN_H_

# pamoja na "stm32f1xx_ll_adc.h"

# pamoja "stm32f1xx_ll_rcc.h" #include "stm32f1xx_ll_bus.h" #include "stm32f1xx_ll_system.h" #include "stm32f1xx_ll_exti.h" #include "stm32f1xx_ll_cortex.h" strst_xx_xx_hiti_hiti_na_na_na_na_na_na_na_na_kufanya_na_na_naweza_kushangaa.h "#shuu_ya_mtoto_wa_mtoto_wa_mtoto_wa_mtoto_wa_mzuri_mtoto_wa_mzuri_mtamu_wa_mzuri_m_mzuri_m_m_mzuri_m_mz.ru" #simulizie ni pamoja na "stm32f1xx_ll_dma.h" # pamoja na "stm32f1xx_ll_spi.h" # pamoja na "stm32f1xx_ll_tim.h" # pamoja na "stm32f1xx.h" #include "stm32f1xx_ll_gpio.h"

#ifndef NVIC_PRIORITYGROUP_0

#fafanua NVIC_PRIORITYGROUP_0 ((uint32_t) 0x00000007) #fafanua NVIC_PRIORITYGROUP_1 ((uint32_t) 0x00000006) #fafanua NVIC_PRIORITYGROUP_2 ((uint32_t) 0x00000005) #define NVIC_PRIXXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXYX8Y0Y0Y0Y0Y0Y0Y0Y0Y082101300000000000000000000000000000000000000000000000000 (# ufuatiliaji (0) 0 (ID) 0 (0) ((040)) (ufafanuzi) (0)

#ifdef _cplusplus

nje "C" {# mwisho ikiwa batili _Error_Handler (char *, int);

#fafanua Kosa_Handler () _Error_Handler (_ FILE_, _LINE_)

#ifdef _cplusplus} # endif

# mwisho

Hatua ya 6: Kuu.c

# pamoja na "main.h" batili tuli LL_Init (batili); utupu SystemClock_Config (utupu); utupu tuli MX_GPIO_Init (batili); utupu tuli MX_ADC1_Init (batili); utupu tuli MX_SPI1_Init (batili); utupu tuli MX_SPI2_Init (batili); utupu tuli MX_TIM3_Init (batili); utupu tuli MX_TIM4_Init (batili);

uint16_t SPI1_send64 (uint16_t data3, uint16_t data2, uint16_t data1, data uint16_t0);

uint16_t SPI2_send64 (uint16_t data3, uint16_t data2, uint16_t data1, data uint16_t0); batili MAX7219_1_init (); batili MAX7219_2_init (); batili kufuta_frame_buffer (batili); batili kujaza_frame_buffer (batili); batili display_frame_buffer (batili); batili set_timebase (batili);

uint8_t maonyesho ya juu [4] [8]; // vier ka naast elkaar, acht onder elkaar

uint8_tazamaji ya chini_ya chini [4] [8]; // deze twee samen vormen de fremu-bafa

uint8_t sampuli_buffer [32]; // bafa ya matokeo ya matokeo ya ADC

kuu (batili)

{LL_Init (); MfumoClock_Config (); MX_GPIO_Init (); MX_ADC1_Init (); MX_SPI1_Init (); MX_SPI2_Init (); MX_TIM3_Init (); MX_TIM4_Init ();

LL_SPI_Iwezesha (SPI1);

LL_SPI_Iwezesha (SPI2);

LL_TIM_IwezeshaCounter (TIM3);

LL_TIM_IwezeshaCounter (TIM4);

LL_ADC_Iwezesha (ADC1);

LL_ADC_REG_StartConversionSWStart (ADC1); LL_ADC_IwezeshaIT_EOS (ADC1);

LL_mDelay (500); // MAX7219 inahitaji muda baada ya kuwasha umeme

MAX7219_1_init (); MAX7219_2_init ();

// LL_TIM_SetAutoReload (TIM3, 9);

wakati (1)

{set_timebase (); futa_frame_buffer (); jaza_frame_buffer (); onyesha_frame_buffer (); }}

batili kufuta_frame_buffer (batili)

{int8_t x; int8_t y;

kwa (x = 0; x <4; x ++) // kolom_bytes {

kwa (y = 0; y <8; y ++) // lijnen {top_display [x] [y] = 0; // alle bitjes op nul lower_display [x] [y] = 0; }}}

batili kujaza_frame_buffer (batili)

{uint8_t y = 0; // voltage uint8_t tijd = 0; // tijd uint8_t onyesha_byte; // inaendesha bits 8 naast elkaar en dat 4 maal op een lijn uint8_t display_bit;

kwa (tijd = 0; tijd <32; tijd ++) {display_byte = tijd / 8; onyesha_bit = 7 - (tijd% 8);

y = sampuli_buffer [tijd];

ikiwa (y> 7) // katika onyesho la juu la schrijven

{top_display [display_byte] [15-y] | = (1 << kuonyesha_bit); } mwingine // katika skrijven ya chini ya kuonyesha {lower_display [display_byte] [7-y] | = (1 << display_bit); }}}

batili ya kuonyesha_frame_buffer (batili)

{

uint8_t y; // acht lijnen boven elkaar (kwa kila onyesho) uint16_t yl; // lijnnummer voor de MAX7219

kwa (y = 0; y <8; y ++) {yl = (y + 1) << 8; // MAX7219 heeft lijnnummer katika de bits 8 za juu van 16 bits woord

SPI2_send64 ((yl | onyesho la juu] [0] [y]), (yl | onyesho la juu];

SPI1_send64 ((yl | sinema ya chini] [0] [y]), (yl | onyesho la chini]; }

}

batili set_timebase (batili)

{uint8_t timebase_knop;

timebase_knop = LL_TIM_GetCounter (TIM4) / 2;

badilisha (timebase_knop)

{kesi 0: LL_TIM_SetAutoReload (TIM3, 1999); kuvunja; kesi 1: LL_TIM_SetAutoReload (TIM3, 999); kuvunja; kesi 2: LL_TIM_SetAutoReload (TIM3, 499); kuvunja; kesi 3: LL_TIM_SetAutoReload (TIM3, 199); kuvunja; kesi ya 4: LL_TIM_SetAutoReload (TIM3, 99); kuvunja; kesi 5: LL_TIM_SetAutoReload (TIM3, 49); kuvunja; kesi ya 6: LL_TIM_SetAutoReload (TIM3, 19); kuvunja; kesi ya 7: LL_TIM_SetAutoReload (TIM3, 9); kuvunja; kesi ya 8: LL_TIM_SetAutoReload (TIM3, 4); kuvunja; kesi 9: LL_TIM_SetAutoReload (TIM3, 1); kuvunja;

chaguomsingi:

LL_TIM_SetAutoReload (TIM3, 99); kuvunja; }}

batili MAX7219_1_init ()

{SPI1_send64 (0x0000, 0x0000, 0x0000, 0x0000); // nop SPI1_send64 (0x0C00, 0x0C00, 0x0C00, 0x0C00); // kuzima kwa SPI1_send64 (0x0000, 0x0000, 0x0000, 0x0000); // nop SPI1_send64 (0x0F00, 0x0F00, 0x0F00, 0x0F00); // testmode mbali SPI1_send64 (0x0C01, 0x0C01, 0x0C01, 0x0C01); // kuzima, operesheni ya kawaida SPI1_send64 (0x0900, 0x0900, 0x0900, 0x0900); // hakuna 7seg decode, saizi 64 SPI1_send64 (0x0A07, 0x0A07, 0x0A07, 0x0A07); // kiwango 50% SPI1_send64 (0x0B07, 0x0B07, 0x0B07, 0x0B07); // safu zote kwenye}

batili MAX7219_2_init ()

{SPI2_send64 (0x0000, 0x0000, 0x0000, 0x0000); // nop SPI2_send64 (0x0C00, 0x0C00, 0x0C00, 0x0C00); // kuzima kwa SPI2_send64 (0x0000, 0x0000, 0x0000, 0x0000); // nop SPI2_send64 (0x0F00, 0x0F00, 0x0F00, 0x0F00); // testmode mbali SPI2_send64 (0x0C01, 0x0C01, 0x0C01, 0x0C01); // kuzima, operesheni ya kawaida SPI2_send64 (0x0900, 0x0900, 0x0900, 0x0900); // hakuna 7seg decode, saizi 64 SPI2_send64 (0x0A07, 0x0A07, 0x0A07, 0x0A07); // kiwango 50% SPI2_send64 (0x0B07, 0x0B07, 0x0B07, 0x0B07); // safu zote kwenye}

uint16_t SPI1_send64 (uint16_t data3, uint16_t data2, uint16_t data1, data uint16_t0)

{LL_GPIO_ResetOutputPin (GPIOA, LL_GPIO_PIN_4);

LL_SPI_TransmitData16 (SPI1, data3);

wakati (LL_SPI_IsActiveFlag_TXE (SPI1) == 0) {}

LL_SPI_TransmitData16 (SPI1, data2);

wakati (LL_SPI_IsActiveFlag_TXE (SPI1) == 0) {}

LL_SPI_TransmitData16 (SPI1, data1);

wakati (LL_SPI_IsActiveFlag_TXE (SPI1) == 0) {}

LL_SPI_TransmitData16 (SPI1, data0);

wakati (LL_SPI_IsActiveFlag_BSY (SPI1) == 1) {}

LL_GPIO_SetOutputPin (GPIOA, LL_GPIO_PIN_4);

kurudi LL_SPI_ReceiveData16 (SPI1); }

uint16_t SPI2_send64 (uint16_t data3, uint16_t data2, data uint16_t1, data uint16_t0)

{LL_GPIO_ResetOutputPin (GPIOB, LL_GPIO_PIN_12);

LL_SPI_TransmitData16 (SPI2, data3);

wakati (LL_SPI_IsActiveFlag_TXE (SPI2) == 0) {}

LL_SPI_TransmitData16 (SPI2, data2);

wakati (LL_SPI_IsActiveFlag_TXE (SPI2) == 0) {}

LL_SPI_TransmitData16 (SPI2, data1);

wakati (LL_SPI_IsActiveFlag_TXE (SPI2) == 0) {}

LL_SPI_TransmitData16 (SPI2, data0);

wakati (LL_SPI_IsActiveFlag_BSY (SPI2) == 1) {}

LL_GPIO_SetOutputPin (GPIOB, LL_GPIO_PIN_12);

kurudi LL_SPI_ReceiveData16 (SPI2); }

utupu ADC1_2_IRQHandler (batili)

{tuli uint8_t sample_counter; uint8_t trigger; tuli uint8_t zamani_trigger;

ikiwa (LL_ADC_IsActiveFlag_EOS (ADC1)! = Rudisha)

{if (sample_counter <32) {sample_buffer [sample_counter] = LL_ADC_REG_ReadConversionData32 (ADC1) / 256; ikiwa (sample_counter <32) sample_counter ++; mwingine sample_counter = 0; } mwingine {trigger = LL_ADC_REG_ReadConversionData32 (ADC1) / 256;

ikiwa ((trigger == 7) && (previous_trigger <trigger)) // gaat niet helemaal goed bij blokgolven… {sample_counter = 0; } uliopita_trigger = kichocheo; }

LL_GPIO_TogglePin (GPIOC, LL_GPIO_PIN_13);

LL_ADC_ClearFlag_EOS (ADC1);

} }

utupu tuli tuli LL_Init (batili)

{LL_APB2_GRP1_Washa Saa (LL_APB2_GRP1_PERIPH_AFIO); LL_APB1_GRP1_Washa Saa (LL_APB1_GRP1_PERIPH_PWR);

NVIC_SetPriorityGrouping (NVIC_PRIORITYGROUP_4);

NVIC_SetPriority (MemoryManagement_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0)); NVIC_SetPriority (BusFault_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0)); NVIC_SetPriority (UsageFault_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0)); NVIC_SetPriority (SVCall_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0)); NVIC_SetPriority (DebugMonitor_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0)); NVIC_SetPriority (PendSV_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0)); NVIC_SetPriority (SysTick_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0));

LL_GPIO_AF_Repap_SWJ_NOJTAG ();

}

utupu SystemClock_Config (utupu)

{LL_FLASH_SetLatency (LL_FLASH_LATENCY_2); ikiwa (LL_FLASH_GetLatency ()! = LL_FLASH_LATENCY_2) Kosa_Handler (); LL_RCC_HSE_Iwasha (); wakati (LL_RCC_HSE_IsIko tayari ()! = 1); LL_RCC_PLL_ConfigDomain_SYS (LL_RCC_PLLSOURCE_HSE_DIV_1, LL_RCC_PLL_MUL_9); LL_RCC_PLL_Washa (); wakati (LL_RCC_PLL_IsReady ()! = 1); LL_RCC_SetAHBMuuzaji (LL_RCC_SYSCLK_DIV_1); LL_RCC_SetAPB1Muuzaji (LL_RCC_APB1_DIV_2); LL_RCC_SetAPB2Prescaler (LL_RCC_APB2_DIV_1); LL_RCC_SetSysClkSource (LL_RCC_SYS_CLKSOURCE_PLL); wakati (LL_RCC_GetSysClkSource ()! = LL_RCC_SYS_CLKSOURCE_STATUS_PLL); LL_Init1msTick (72000000); LL_SYSTICK_SetClkSource (LL_SYSTICK_CLKSOURCE_HCLK); LL_SetSystemCoreClock (72000000); LL_RCC_SetADCClockSource (LL_RCC_ADC_CLKSRC_PCLK2_DIV_6);

NVIC_SetPriority (SysTick_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0));

}

utupu tuli MX_ADC1_Init (batili)

{LL_ADC_InitTypeDef ADC_InitStruct; LL_ADC_CommonInitTypeDef ADC_CommonInitStruct; LL_ADC_REG_InitTypeDef ADC_REG_InitStruct; LL_GPIO_InitTypeDef GPIO_InitStruct;

LL_APB2_GRP1_Washa Saa (LL_APB2_GRP1_PERIPH_ADC1);

GPIO_InitStruct. Pin = LL_GPIO_PIN_0;

GPIO_InitStruct. Mode = LL_GPIO_MODE_ANALOG; LL_GPIO_Init (GPIOA, & GPIO_InitStruct);

NVIC_SetPriority (ADC1_2_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0));

NVIC_InawezeshwaIRQ (ADC1_2_IRQn);

ADC_InitStruct. DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;

ADC_InitStruct. SequencersScanMode = LL_ADC_SEQ_SCAN_DISABLE; LL_ADC_Init (ADC1, & ADC_InitStruct);

ADC_CommonInitStruct. Multimode = LL_ADC_MULTI_INDEPENDENT;

LL_ADC_CommonInit (_ LL_ADC_COMMON_INSTANCE (ADC1), & ADC_CommonInitStruct);

ADC_REG_InitStruct. TriggerSource = LL_ADC_REG_TRIG_EXT_TIM3_TRGO;

ADC_REG_InitStruct. SequencerLength = 1; ADC_REG_InitStruct. SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; ADC_REG_InitStruct. ContinuousMode = LL_ADC_REG_CONV_SINGLE; ADC_REG_InitStruct. DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE; LL_ADC_REG_Init (ADC1, & ADC_REG_InitStruct);

LL_ADC_SetChannelSamplingTime (ADC1, LL_ADC_CHANNEL_0, LL_ADC_SAMPLINGTIME_41CYCLES_5);

}

utupu tuli MX_SPI1_Init (batili)

{LL_SPI_InitTypeDef SPI_InitStruct; LL_GPIO_InitTypeDef GPIO_InitStruct;

LL_APB2_GRP1_Washa Saa (LL_APB2_GRP1_PERIPH_SPI1);

GPIO_InitStruct. Pin = LL_GPIO_PIN_5 | LL_GPIO_PIN_7;

GPIO_InitStruct. Mode = LL_GPIO_MODE_ALTERNATE; GPIO_InitStruct. Speed = LL_GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct. OutputType = LL_GPIO_OUTPUT_PUSHPULL; LL_GPIO_Init (GPIOA, & GPIO_InitStruct);

// NVIC_SetPriority (SPI1_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0));

// NVIC_IwezeshaIRQ (SPI1_IRQn);

SPI_InitStruct. TransferDirection = LL_SPI_FULL_DUPLEX;

SPI_InitStruct. Mode = LL_SPI_MODE_MASTER; SPI_InitStruct. DataWidth = LL_SPI_DATAWIDTH_16BIT; SPI_InitStruct. ClockPolarity = LL_SPI_POLARITY_LOW; SPI_InitStruct. ClockPhase = LL_SPI_PHASE_1EDGE; SPI_InitStruct. NSS = LL_SPI_NSS_SOFT; SPI_InitStruct. BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV8; SPI_InitStruct. BitOrder = LL_SPI_MSB_FIRST; SPI_InitStruct. CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE; SPI_InitStruct. CRCPoly = 10; LL_SPI_Init (SPI1, & SPI_InitStruct); }

utupu tuli MX_SPI2_Init (batili)

{LL_SPI_InitTypeDef SPI_InitStruct; LL_GPIO_InitTypeDef GPIO_InitStruct;

LL_APB1_GRP1_Washa Saa (LL_APB1_GRP1_PERIPH_SPI2);

GPIO_InitStruct. Pin = LL_GPIO_PIN_13 | LL_GPIO_PIN_15;

GPIO_InitStruct. Mode = LL_GPIO_MODE_ALTERNATE; GPIO_InitStruct. Speed = LL_GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct. OutputType = LL_GPIO_OUTPUT_PUSHPULL; LL_GPIO_Init (GPIOB, & GPIO_InitStruct);

// NVIC_SetPriority (SPI2_IRQn, NVIC_EncodePriority (NVIC_GetPriorityGrouping (), 0, 0));

// NVIC_IwezeshaIRQ (SPI2_IRQn);

SPI_InitStruct. TransferDirection = LL_SPI_FULL_DUPLEX;

SPI_InitStruct. Mode = LL_SPI_MODE_MASTER; SPI_InitStruct. DataWidth = LL_SPI_DATAWIDTH_16BIT; SPI_InitStruct. ClockPolarity = LL_SPI_POLARITY_LOW; SPI_InitStruct. ClockPhase = LL_SPI_PHASE_1EDGE; SPI_InitStruct. NSS = LL_SPI_NSS_SOFT; SPI_InitStruct. BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV4; SPI_InitStruct. BitOrder = LL_SPI_MSB_FIRST; SPI_InitStruct. CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE; SPI_InitStruct. CRCPoly = 10; LL_SPI_Init (SPI2, & SPI_InitStruct); }

utupu tuli MX_TIM3_Init (batili)

{LL_TIM_InitTypeDef TIM_InitStruct;

LL_APB1_GRP1_Washa Saa (LL_APB1_GRP1_PERIPH_TIM3);

TIM_InitStruct. Prescaler = 229;

TIM_InitStruct. CounterMode = LL_TIM_COUNTERMODE_UP; TIM_InitStruct. Upakiaji wa mzigo = 9; TIM_InitStruct. ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; LL_TIM_Init (TIM3, & TIM_InitStruct);

LL_TIM_DisableARRPpakia upya (TIM3);

LL_TIM_SetClockSource (TIM3, LL_TIM_CLOCKSOURCE_INTERNAL); LL_TIM_SetTriggerOutput (TIM3, LL_TIM_TRGO_UPDATE); LL_TIM_WezeshaMasterSlaveMode (TIM3); }

utupu tuli MX_TIM4_Init (batili)

{LL_TIM_InitTypeDef TIM_InitStruct; LL_GPIO_InitTypeDef GPIO_InitStruct;

LL_APB1_GRP1_Washa Saa (LL_APB1_GRP1_PERIPH_TIM4);

GPIO_InitStruct. Pin = LL_GPIO_PIN_6 | LL_GPIO_PIN_7;

GPIO_InitStruct. Mode = LL_GPIO_MODE_FLOATING; LL_GPIO_Init (GPIOB, & GPIO_InitStruct);

LL_TIM_SetEncoderMode (TIM4, LL_TIM_ENCODERMODE_X2_TI1);

LL_TIM_IC_SetActiveInput (TIM4, LL_TIM_CHANNEL_CH1, LL_TIM_ACTIVEINPUT_DIRECTTI); LL_TIM_IC_SetPrescaler (TIM4, LL_TIM_CHANNEL_CH1, LL_TIM_ICPSC_DIV1); LL_TIM_IC_SetFilter (TIM4, LL_TIM_CHANNEL_CH1, LL_TIM_IC_FILTER_FDIV1); LL_TIM_IC_SetPolarity (TIM4, LL_TIM_CHANNEL_CH1, LL_TIM_IC_POLARITY_RISING); LL_TIM_IC_SetActiveInput (TIM4, LL_TIM_CHANNEL_CH2, LL_TIM_ACTIVEINPUT_DIRECTTI); LL_TIM_IC_SetPrescaler (TIM4, LL_TIM_CHANNEL_CH2, LL_TIM_ICPSC_DIV1); LL_TIM_IC_SetFilter (TIM4, LL_TIM_CHANNEL_CH2, LL_TIM_IC_FILTER_FDIV1); LL_TIM_IC_SetPolarity (TIM4, LL_TIM_CHANNEL_CH2, LL_TIM_IC_POLARITY_RISING);

TIM_InitStruct. Prescaler = 0;

TIM_InitStruct. CounterMode = LL_TIM_COUNTERMODE_UP; TIM_InitStruct. Upakiaji wa mzigo = 19; TIM_InitStruct. ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; LL_TIM_Init (TIM4, & TIM_InitStruct);

LL_TIM_DisableARRPpakia upya (TIM4);

LL_TIM_SetTriggerOutput (TIM4, LL_TIM_TRGO_RESET); LL_TIM_DisableMasterSlaveMode (TIM4); }

utupu tuli MX_GPIO_Init (batili)

{LL_GPIO_InitTypeDef GPIO_InitStruct;

LL_APB2_GRP1_Washa Saa (LL_APB2_GRP1_PERIPH_GPIOC);

LL_APB2_GRP1_Washa Saa (LL_APB2_GRP1_PERIPH_GPIOD); LL_APB2_GRP1_Washa Saa (LL_APB2_GRP1_PERIPH_GPIOA); LL_APB2_GRP1_Washa Saa (LL_APB2_GRP1_PERIPH_GPIOB);

LL_GPIO_SetOutputPin (GPIOC, LL_GPIO_PIN_13);

LL_GPIO_SetOutputPin (GPIOA, LL_GPIO_PIN_4); LL_GPIO_SetOutputPin (GPIOB, LL_GPIO_PIN_12);

GPIO_InitStruct. Pin = LL_GPIO_PIN_13;

GPIO_InitStruct. Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct. Speed = LL_GPIO_SPEED_FREQ_LOW; GPIO_InitStruct. OutputType = LL_GPIO_OUTPUT_PUSHPULL; LL_GPIO_Init (GPIOC, & GPIO_InitStruct);

GPIO_InitStruct. Pin = LL_GPIO_PIN_4;

GPIO_InitStruct. Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct. Speed = LL_GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct. OutputType = LL_GPIO_OUTPUT_PUSHPULL; LL_GPIO_Init (GPIOA, & GPIO_InitStruct);

GPIO_InitStruct. Pin = LL_GPIO_PIN_12;

GPIO_InitStruct. Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct. Speed = LL_GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct. OutputType = LL_GPIO_OUTPUT_PUSHPULL; LL_GPIO_Init (GPIOB, & GPIO_InitStruct); }

batili _Error_Handler (faili ya char *, mstari wa int)

{wakati (1) {}}

#ifdef USE_FULL_ASSERT

batili assert_failed (uint8_t * faili, uint32_t line)

{} # mwisho

Ilipendekeza: