프로그램/ATMega 17

ATMega128 UART 통신 샘플(RS232, 0번 USART)

후배한테 소스 주면서... 이참에 밀린 소스도 정리할 겸... 공개해 드립니다~ 유용하게 사용하시길 바랍니다~ main.c #include "main.h" #include "serial.h" int main(void) { Init_Uart0(); sei(); while(1) { sleep(); } return 0; } main.h #ifndef __MAIN_HEADER__ #define sei() __asm__ __volatile__ ("sei" ::) #define sleep() __asm__ __volatile__ ( "sleep" "\n\t" :: ) #endif // __MAIN_HEADER__ serial.c #include "serial.h" unsigned char Uart_ReadChar(..

프로그램/ATMega 2010.04.02

IAR 컴파일러 Warning : undefined behavior: the order of volatile accesses is undefined in this statement

얼마 전 후배의 질문이 있어 답변했다가 문득 정리해 두어야 하지 않을까 싶어 정리해 본다. 후배가 IAR 컴파일러로 컴파일 할 때 아래와 같은 워닝이 떠 제거하기 위해 검색했다고 한다. Warning : undefined behavior: the order of volatile accesses is undefined in this statement 관련된 소스를 대충 살펴 보면 아래와 같다. volatile int iPinA; volatile int iPinB; // ...... iPinB *= iPinA; 밑출친 부분에서 워닝이 감지된다. 이는 volatile에 대한 정확한 인지가 문제이다. 이걸 설명한 댓글에 보니까 컴파일러가 좋지 않아서 그렇다는 댓글도 봤는데 그건 상용 컴파일러에 대한 인지가 더 ..

프로그램/ATMega 2010.04.01