RTC하고 타이머로 시간 정보를 수정하고 싶은데
페이지 정보
작성자 라칸 작성일23-01-04 11:37 조회453회 댓글1건본문
stm32에서 RTC하고 타이머로 시간값을 만들고 불러오기를 했는데
이걸 메시지를 보내서 수정하도록 하려고 하니까
rtc로 작동시킨게 문제인지 타이머로 계속돌린게 문제인지 메시지도 보내서 수정하는게 안되네요
이걸 어떻게하면 메시지를 받았을때 uploadTime을 바뀔수 있을까요?
------------------------------------------
코드
static void RTC_CalendarShow(void)
{
RTC_DateTypeDef sdatestructureget;
RTC_TimeTypeDef stimestructureget;
/* Get the RTC current Time */
HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN);
/* Get the RTC current Date */
HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN);
uploadTime = ((2000+sdatestructureget.Year)-1970)*31556926;
uploadTime += (sdatestructureget.Month-1)*2629743;
uploadTime += (sdatestructureget.Date-2)*86400;
uploadTime += (stimestructureget.Hours)*3600;
uploadTime += (stimestructureget.Minutes)*60;
uploadTime += stimestructureget.Seconds;
uploadTime = (uploadTime - 24180);
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
if (htim->Instance == TIM1) {
HAL_IncTick();
}
/* USER CODE BEGIN Callback 1 */
if(htim->Instance == TIM6)
{
RTC_CalendarShow();
// 현재 주기마다 데이터 측정
// 데이터 전송 주기
}
/* USER CODE END Callback 1 */
}
------------------------------
//시간 값 수정시킬때
settime[0] = (unsigned int)body_q[1];
settime[1] = (unsigned int)body_q[2];
settime[2] = (unsigned int)body_q[3];
settime[3] = (unsigned int)body_q[4];
uploadTime = ((settime[0] << 24) | (settime[1] << 16) | (settime[2] << 8) | settime[3]);
//여기까지는 값이 잘 들어왔습니다
근데 메시지로 출력시킬때 값이 변화가 없더군요
extern unsigned int uploadTime; 외부 참조가 문제인가요?
댓글 : 1
조회수 : 453
master님의 댓글
master 작성일
/* Get the RTC current Time */
HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN);
/* Get the RTC current Date */
HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN);
Get 함수 말고 Save 함수 같은 것이 있을텐데요?
예제를 찾아서 공부해보세요