본문 바로가기

stm32f1

(31)
34.[stm32f103][hal] CDC Printf 적용하기 https://hnydiy.tistory.com/76 28.[stm32f103][hal] CDC-Virtual Port Com 0. driver 1. STM32 Cube 2. 소스 usbd_cdc_if.c static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) { /* USER CODE BEGIN 6 */ USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); Buf[*Len] = 0; //.. hnydiy.tistory.com 위에 포스터 처럼 CUBE 적용하시면 됩니다. main.c /* Includes ------------------------------------------------------------------*/ ..
33.[stm32f103][hal] 소프트 리셋 Code : NVIC_SystemReset();
32.[stm32f103][hal] usart1 Interrupt 1. STM32CubeMX 첫 번째 방법 #include "main.h" #include "stm32f1xx_hal.h" /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ UART_HandleTypeDef huart1; /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ uint8_t RxBuffer[1]; int main(void) { MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ HAL_UART_Receive_IT(&huart1, RxBuffer, 1); while (1)..
31.[stm32f103][hal] OLED SSD1306 0. 파일 참고 사이트https://github.com/afiskon/stm32-ssd1306 구매 사이트http://www.devicemart.co.kr/1382233 1. STM32Cube 설정이미 풀업 저항이 달려서 나온 제품~!! 2. 파일 설정 폴더를 열면 Inc 폴더엔 .h 파일을 Src 폴더엔 .c 파일을 넣으면 됩니다. 3. IAR 설정 4. 소스 main.c#include "main.h"#include "stm32f1xx_hal.h" /* USER CODE BEGIN Includes */#include "ssd1306_tests.h"/* USER CODE END Includes */ /* Private variables --------------------------------------..
30.[stm32f103][hal] us delay 만들기 0. 파일 1. STM32Cube 2. 파일 추가 3. 소스 main.c int main(void){ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE B..
29.[stm32f103][hal] i2c_AT2402 eeprom 0. 파일 1. STM32Cube I2c 를 사용하려면 2가지 방법이 있습니다.첫번째는 GPIO를 사용하여 직접 제어 는장점 - Pull up 저항 안달아도됨 직관적인 제어 두번째는 내부 함수를 사용해서 제어하는 방법입니다.근데 하다보니 Clock Configuration 에서 2Mhz 이상 설정하면 I2C가 안되는 문제가 있는거 같습니다.그래서 위에 Cube 설정에서 2Mhz 로 맞춘 이유가 그것입니다. 2. 소스user_I2c.c #include "stm32f1xx_hal.h" int at24_HAL_WriteBytes(I2C_HandleTypeDef *hi2c,uint16_t DevAddress,uint16_t MemAddress, uint8_t *pData,uint16_t TxBufferSize)..
28.[stm32f103][hal] CDC-Virtual Port Com 0. driver 1. STM32 Cube 2. 소스 usbd_cdc_if.c static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) { /* USER CODE BEGIN 6 */ USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]); Buf[*Len] = 0; // last Add Null USBD_CDC_ReceivePacket(&hUsbDeviceFS); return (USBD_OK); /* USER CODE END 6 */ } main.c #include "main.h" #include "stm32f1xx_hal.h" #include "usb_device.h" /* USER CODE BEGIN Includes */ #def..
27.[stm32f103][hal] ADC (3) -DMA ADC 0. 파일 1. STM32CubeMx 2. 소스 설명 DMA 를 이용하여 arDMA1_ADC1[] 배열로 값을 저장 하고 64 번의 평균을 내서 USER.Adc 의 AvgADC 값에 저장한다. 3. Main.c /*Includes------------------------------------------------------------------*/ #include "main.h" #include "stm32f1xx_hal.h" /*USER CODE BEGIN Includes*/ #include "user_ADC_DMA.h" /*USER CODE END Includes*/ /*Private variables-------------------------------------------------------..