마이크로프로세서
PC의 CPU
고속 연산과 대용량 메모리 처리
인텔 펜티엄등
MPU
마이크로컨트롤러
기계나 장치를 제어하기 위해 사용하는 프로그램이 가능한 칩
CPU, 기본 메모리, I/O 포트, 타이머, 직렬 통신 등의 기능을 하나의 칩에 내장
인텔 8051, AVR, PIC 등
MCU
TC275 보드 소개


리셋 회로 질문좀 드리자(궁금증) 리셋 버튼 누르면 어떻게 되는지
리셋에 아무런 값이 인가되어있지 않다가 gnd와 연결되어서 reset 신호가 칩에 전달됨.

GPIO 레지스터 설정
p10.2를 출력 모드 동작으로 하기 위해서는 어떤 레지스터 설정?
어떤건 shieldbuddy를 보고 어떤건 d-step을 봐야 하지??(궁금증)
핀과 관련된 것을 보고 싶다 -> shieldbuddy
칩의 기능과 관련된 것을 보고 싶다 -> d-step




이 중에서 어떤 레지스터에 어떤 값? -> Register Pn_IOCR0 controls the Pn.[3:0] port lines

비트 5개 짜리도 레지스터라고 하는가? (궁금증) 정확히 어떤 것을 레지스터라고 지칭하는가?
노노 이 칩에서는 32비트가 register


#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#define PCn_2_IDX 19
#define P2_IDX 2
IfxCpu_syncEvent g_cpuSyncEvent = 0;
void initLED(void);
int core0_main(void)
{
IfxCpu_enableInterrupts();
/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdogs and service them periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
initLED();
while(1)
{
P10_OUT.U = 0x1 << P2_IDX;
}
return (1);
}
void initLED(){
P10_IOCR0.U &= ~(0x1F << PCn_2_IDX);
P10_IOCR0.U |= 0X10 << PCn_2_IDX;
}



#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#define PCn_2_IDX 19
#define P2_IDX 2
#define PCn_1_IDX 11
#define P1_IDX 1
IfxCpu_syncEvent g_cpuSyncEvent = 0;
void initGPIO(void);
int core0_main(void)
{
IfxCpu_enableInterrupts();
/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdogs and service them periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
initGPIO();
while(1)
{
if((P02_IN.U & (0x1 << P1_IDX)) == 0){
P10_OUT.U |= 0x1 << P2_IDX;
}
else{
P10_OUT.U |= 0x0 << P2_IDX;
}
}
return (1);
}
void initGPIO(){
P02_IOCR0.U &= ~(0x1F << PCn_1_IDX);
P02_IOCR0.U |= 0x02 << PCn_1_IDX;
P10_IOCR0.U &= ~(0x1F << PCn_2_IDX);
P10_IOCR0.U |= 0x10 << PCn_2_IDX;
}
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#define PCn_2_IDX 19
#define P2_IDX 2
#define PCn_1_IDX 11
#define P1_IDX 1
IfxCpu_syncEvent g_cpuSyncEvent = 0;
void initGPIO(void);
int core0_main(void)
{
IfxCpu_enableInterrupts();
/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdogs and service them periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
while(1)
{
if(P02_IN.U & (0x1 << P1_IDX) == 0){
P10_OUT.U = 0x1 << P1_IDX;
}
else{
P10_OUT.U = 0x1 << P2_IDX;
}
}
return (1);
}
void initLED(){
P02_IOCR0.U &= ~(0x1F << PCn_1_IDX);
P02_IOCR0.U |= 0x02 << PCn_1_IDX;
P10_IOCR0.U &= ~(0x1F << PCn_2_IDX);
P10_IOCR0.U |= 0X10 << PCn_2_IDX;
P10_IOCR0.U &= ~(0x1F << PCn_1_IDX);
P10_IOCR0.U |= 0x10 << PCn_1_IDX;
}
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#define PCn_2_IDX 19
#define P2_IDX 2
#define PCn_1_IDX 11
#define P1_IDX 1
IfxCpu_syncEvent g_cpuSyncEvent = 0;
void initGPIO(void);
int core0_main(void)
{
IfxCpu_enableInterrupts();
/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdogs and service them periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
static unsigned int prev;
static unsigned int now;
while(1)
{
now = P02_IN.U & (0x1 << P1_IDX) == 0;
if(now && !prev){
P10_OMR.U = 0x20002;
}
prev = now;
}
return (1);
}
void initLED(){
P02_IOCR0.U &= ~(0x1F << PCn_1_IDX);
P02_IOCR0.U |= 0x02 << PCn_1_IDX;
P10_IOCR0.U &= ~(0x1F << PCn_1_IDX);
P10_IOCR0.U |= 0x10 << PCn_1_IDX;
}
변수는 한번에 하나씩 따로 선언해라
unsigned char preSW, curSW; -> 이렇게 하지마
코드 한줄에 다섯 클락에서 열 클락 정도 사용한다.
while문 열클락
따라서 while문 안쪽이 총 30클락 정도
3번째 예시 150 ms 안에 눌렀다 때지 않는 이상 잘 동작한다는 거죠
10초 이상 누르면 integer overflow 난다는 거지(질문) -> max가 되면 wrap around가 일어나서 (0부터 다시 시작) unsigned int이기 때문에.
cnt 값이 1000안쪽에 들어올 수 있다.
1번 2번을 보통 사용한다.
1번이 최고.
참고 - delay는 너무 커도 문제고 너무 작아도 문제 => 가장 선호되지 않는 방법
이런 레지스터들은 매 사이클 마다 계속 알아서 초기화해서 비트를 계속 안 초기화해줘도 된다.
원래는 이런것도 datasheet에 명시가 되어있는데 얘는 워낙 유명해서 안돼있는거같다...?
read as 0가 초기화된다는 의미인 것 같다.