打印

PSoC5 计数器问题

[复制链接]
2297|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
noyuan2007|  楼主 | 2011-5-26 21:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
小弟是PSoC5的初学者,现在准备用Counter做一个信号发生器的频率控制,在其计数周期满了之后,让波形表中数据输出一个,DA输出,不断循环,然后完成波形的输出,但是这样做出来结果不行,波形一半正弦波 一半杂波,并且频率最高只有1.5k的样子,怎么想都不知道问题在哪儿,故想向各位大侠求解,在此谢过了
下面是我的程序段:
#include <device.h>
const uint8 voltageSineWave[400] =
{
64,65,66,67,68,70,71,72,73,74,75,76,77,78,79,81,82,83,84,85,  
86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,103,104,105,  
106,107,108,108,109,110,111,112,112,113,114,114,115,116,116,117,118,118,119,119,120,
121,121,122,122,122,123,123,124,124,125,125,125,126,126,126,126,127,127,127,127,127,
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,127,127,127,127,126,  
126,126,126,125,125,125,124,124,123,123,122,122,122,121,121,120,119,119,118,118,117,
116,116,115,114,114,113,112,112,111,110,109,108,108,107,106,105,104,103,103,102,101,  
100,99,98,97,96,95,94,93,92,91,90,89,88,87,86,85,84,83,82,81,79,78,   
77,76,75,74,73,72,71,70,68,67,66,65,64,63,62,61,60,58,57,56,55,   
54,53,52,51,50,49,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,   
32,31,30,29,28,27,26,25,25,24,23,22,21,20,20,19,18,17,16,16,15,   
14,14,13,12,12,11,10,10,9,9,8,7,7,6,6,6,5,5,4,4,3,   
3,3,2,2,2,2,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,   
0,0,0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,4,4,5,5,   
6,6,6,7,7,8,9,9,10,10,11,12,12,13,14,14,15,16,16,17,18,19,
20,20,21,22,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,   
40,41,42,43,44,45,46,47,49,50,51,52,53,54,55,56,57,58,60,61,62,63
};
uint16 f = 10000;
uint16 i=0;
void main()
{
CYGlobalIntDisable;
VDAC8_1_Start(); /* Initializes VDAC8 with default values */
Opamp_1_Start(); /* Enables Opamp and sets power level */
isr_1_Start();
CYGlobalIntEnable;
uint16 Period = 3000000/(122*f);/*3000000为时钟频率,122为所取波形表点数*/
Counter_1_Start();
Counter_1_WritePeriod(Period);
while(1);
}


中断程序:
extern uint16 voltageSineWave[400];
extern uint16 i;
void isr_1_Interrupt(void)
{
    /*  Place your Interrupt code here. */
    /* `#START isr_1_Interrupt` */
Counter_1_Stop();
isr_1_Disable();
Counter_1_ReadStatusRegister();


VDAC8_1_SetValue(voltageSineWave[i]); /* transport to AD */
i=i+3;
if(i>=360)
{
  i=0;
}
isr_1_Enable();
Counter_1_Start();
    /* `#END` */
}
沙发
noyuan2007|  楼主 | 2011-5-26 21:28 | 只看该作者
对了 ,忘了告诉大家我使用的是PSoC Creator的开发平台

使用特权

评论回复
板凳
noyuan2007|  楼主 | 2011-5-27 13:52 | 只看该作者
有没有高手能做一个PSoC5的计数器程序范例出来啊?感谢各位啊~~:D

使用特权

评论回复
地板
hanwe| | 2011-9-14 13:37 | 只看该作者
有没有高手能做一个PSoC5的计数器程序范例出来啊?感谢各位啊~~:D
noyuan2007 发表于 2011-5-27 13:52
我也需要一个

使用特权

评论回复
5
FVJFIFE| | 2011-9-14 20:20 | 只看该作者
好复杂的程序啊

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

5

帖子

1

粉丝