Eddy DK 보드에 1ms 타이머 쓰기

Posted at 2010/03/17 23:19 // in Programming // by Daniel

지금 보드가 없으므로 검색 이후  말로만 하는 거임(틀릴 수 있음)

Eddy DK 보드는 CPU가 Atmel의 AT91SAM9260임

이 칩은 TC타이머가 6개 있음

그런데 Eddy DK의 OS인 레모닉스-리눅스를 조금 고친 것 같은데 소스를 일부만 줌-에서는 타이머 관련 코드가 살아있지 않음 (메모리 영역도 안잡혀있음. 소스를 안준 부분이 있어서 커널 컴파일도 다시 못함)

그래서 직접 하드웨어에 억세스하도록 하고 타이머 돌려보려고 했으나 실패(인터럽트는 커녕 타이머 자체가 돌지 않음)

결국 외부 GPIO에 붙여서 인터럽트 걸어서 사용

 

인터넷을 검색해본 결과 두 가지를 알 수 있었음

1. hrtimer를 쓰면 된다고 하는 사람이 있음

hrtimer는 config에 있는 것을 보았다 – 그런데 nanosleep같은 애들에서 쓴다던데 제대로 안됐다고 하는 거 같음

 

2. tclib이란 게 atmel에서 서포트한 코드가 커널에 있음

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=67424

include/linux/atmel_tc.h and drivers/misc/atmel_tclib.c

drivers/clocksource/tcb_clksrc.c can be used as an example of how to use

tclib.

근데 레모닉스에는 일단 tclib이 enable안돼있음(config) 어찌됐든 코드를 붙여넣거나 해서 써야 함

 

 

참고

http://www.mail-archive.com/linux-kerne ··· 782.html
[patch 2.6.25-rc2-git 1/2] atmel_tc library

tclib이라고 원래 atmel 칩 용으로 타이머 라이브러리가 있음..

http://www.spinics.net/lists/arm-kernel/msg58764.html
Arg! Why is it always the case that I find the answer just after I submit the question ... I needed to SYNC the Timer Block. See below for correction.

> __raw_writel(1000, tcaddr + ATMEL_TC_REG(REG_OFFSET, RC));
> __raw_writel(0x0000, tcaddr + ATMEL_TC_REG(REG_OFFSET, RA));
> __raw_writel(0x0000, tcaddr + ATMEL_TC_REG(REG_OFFSET, RB));
> __raw_writel(0xff, tcaddr + ATMEL_TC_REG(REG_OFFSET, IDR));  /* no irqs */
> __raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(REG_OFFSET, CCR));
>
>  
__raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
> at91_set_B_periph(AT91_PIN_PA19, 0);    /* TIOA1 */
>
> clocksource_register(&clksrc);
>
> ----- UNSNIP ----
>  
My device driver is probably deprecated by the new generic PWM lib from Bill, but I have to release with what I've got.

Aras

크리에이티브 커먼즈 라이센스
Creative Commons License

이 글에는 트랙백을 보낼 수 없습니다