- 论坛徽章:
- 0
|
有一段atmel 9263的代码 对9263不熟 手册看的晕乎乎的-
- /* Prepare TCx to reload automaticly on RC compare */
- at91_tc_write(AT91_TC_CCR, AT91_TC_CLKDIS);
- at91_tc_write(AT91_TC_CMR, AT91_TC_TIMER_CLOCK3 | AT91_TC_WAVESEL_UP_AUTO | AT91_TC_WAVE);
- at91_tc_write(AT91_TC_RC, rt_times.periodic_tick);
- at91_tc_write(AT91_TC_CCR, AT91_TC_CLKEN | AT91_TC_SWTRG);
复制代码 这应该是设置reload模式 在每次从0计数到RC的时候,就trigger
一开始是始终禁止,然后设置CMR寄存器 选择时钟3 wave模式 后面设置RC的值 最后就是时钟使能,并且软件触发开始计数。不知我理解的对不
我想在2440上实现类似上面的功能 应该怎么写呢?
我想的是通过计数器4来实现- #define rTCON (*(volatile unsigned int *) S3C2410_TCON)
- #define rTCNTB4 (*(volatile unsigned int*) S3C2410_TCNTB(4))
- #define rTCMPB4 (*(volatile unsigned int*) S3C2410_TCMPB(4))
- int tcon;
- tcon = rTCON;
- tcon = tcon & ~(1 << 20) ;
- rTCON = tcon;//这里是stop timer4
- rTCNTB4 = 0xFFFF-rt_times.periodic_tick; //因为at91的计数器是递增的,而2440的是递减的所以这里用0xffff减去
- rTCMPB4 = 0;
- tcon = rTCON | (1 << 21) || (1 << 22) ; //2440 mannul update
- rTCON = tcon;
- tcon = rTCON | (1 << 20);//start timer4
- rTCON = tcon;
复制代码 不知我这样写对不对 thanks very very much |
|