FW 심화 과정/[2] STM32심화실습 36

0816 조도센서 / 가속도온도 센서 실습 (MPU-6000)

조도센서 튀는 값 보정 // 0816 cds HAL_ADC_Start(&hadc1); float a =0.9, b=0.1, newValue; int cnt; newValue = HAL_ADC_GetValue(&hadc1); while(1) { newValue = newValue * a + HAL_ADC_GetValue(&hadc1) * b; HAL_Delay(10); cnt ++ ; if ((cnt % 50)==0) printf("newvalue : %d oldvalue : %d \r\n", (uint32_t)(newValue+0.5), HAL_ADC_GetValue(&hadc1)); } 0.5를 더해줌으로써 정수 캐스팅 (반올림) dma를 사용해 조도 센서 값 받기 while(1) // dma cds ..

0811 PWM / FND

cubeMX 에서 설정한 핀 PC10핀 - UART3_TX, PC11핀 - UART3_RX 연결해서 보드와의 UART 송수신이 가능하게 설정한다. 코드1. 조이스틱을 led 컨트롤 // 0809 joystick -> LED control if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) == GPIO_PIN_SET) HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12 | GPIO_PIN_13, GPIO_PIN_SET); if (HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_7) != GPIO_PIN_SET) HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12 | GPIO_PIN_13, GPIO_PIN_SET); else HAL..

0808 netsted(중첩) / priority(우선순위) Interrupt

/* -> NON ATOMIC OPERATION __set_PRIMASK(1); rGPIOD->ODR = rGPIOD -> ODR ^ (0X1 ATOMIC OPERATION bGPIOD_ODR_13 = 1; bGPIOD_ODR_13 = 0; 위 코드는 main문에서 실행되는 코드 non alias 메모리를 통해서 작동하기 위해서는 __set_PRIMASK 로 임계영역을 설정해줘야 함 alias 메모리를 사용하면, 임계영역 설정해주지 않아도 됨 // priority of irq6 *(char *) 0xE000E406 = 0x30; // priority of irq23 *(char *) 0xE000E417 = 0x40; // priority of irq15 *(char *) 0xE000E428 = 0x50;..