当前位置: 技术问答>linux和unix
pwm寄存器操作问题!
来源: 互联网 发布时间:2016-05-01
本文导语: 在做time0计数器实验的时候设置占空比为50%,在中断函数中用count计数pwm的波形数! 这样配置后count一直没改变!/proc/interrupter文件中的中断计数也没变! # cat /proc/interrupts CPU0 17: 7 jianpan 18: 0 jianpan 19: 0 jianpan...
在做time0计数器实验的时候设置占空比为50%,在中断函数中用count计数pwm的波形数!
这样配置后count一直没改变!/proc/interrupter文件中的中断计数也没变!
# cat /proc/interrupts
CPU0
17: 7 jianpan
18: 0 jianpan
19: 0 jianpan
25: 0 s3c2410-wdt
26: 0 time
30: 23948 S3C2410 Timer Tick
42: 0 ohci_hcd:usb1
53: 107 eth0
70: 233 s3c2410-uart
71: 341 s3c2410-uart
配置代码:
if(request_irq(IRQ_TIMER0,&timecount,SA_INTERRUPT,"time",NULL))
return -1;
local_irq_save(mask);
TCNTB0= (unsigned long)ioremap((unsigned long)0x5100000C,4);
*(volatile unsigned long *)TCNTB0= 329;
TCMPB0= (unsigned long)ioremap((unsigned long)0x51000010,4);
*(volatile unsigned long *)TCMPB0= 164;
TCFG0=(unsigned long)ioremap((unsigned long)0x51000000,4);
*(volatile unsigned long *)TCFG0&=0xffffff00;
*(volatile unsigned long *)TCFG0 |=1;
TCFG1=(unsigned long)ioremap((unsigned long)0x51000004,4);
*(volatile unsigned long *)TCFG1&=0xfffffff0;
TCON=(unsigned long)ioremap((unsigned long)0x51000008,4);
*(volatile unsigned long *)TCON&=0x7fffe0;
*(volatile unsigned long *)TCON |=0x09;
local_irq_restore(mask);
|
从你贴出的代码来看,感觉没什么大问题。你把TCON改成下面看看,加了第三行。
TCON=(unsigned long)ioremap((unsigned long)0x51000008,4);
*(volatile unsigned long *)TCON&=0x7fffe0;
*(volatile unsigned long *)TCON |=0x0a;
*(volatile unsigned long *)TCON |=0x09;
最好接示波器看看有没有波形出来,看看是pwm还是中断的问题。你要不急的话把代码发给我我调调看,呵呵。
TCON=(unsigned long)ioremap((unsigned long)0x51000008,4);
*(volatile unsigned long *)TCON&=0x7fffe0;
*(volatile unsigned long *)TCON |=0x0a;
*(volatile unsigned long *)TCON |=0x09;
最好接示波器看看有没有波形出来,看看是pwm还是中断的问题。你要不急的话把代码发给我我调调看,呵呵。
|
周一我调调看吧
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。