在线时间1 小时
UID199331
注册时间2010-7-12
NXP金币0
该用户从未签到
新手上路

- 积分
- 33
- 最后登录
- 1970-1-1
|
发表于 2012-7-29 11:48:49
|
显示全部楼层
回复:请教关于K60 PDB的使用
回复第 4 楼 于2012-07-23 12:25:44发表:
就我理解的,你看看,
如果PDB做ADC选择通道延时以及转换时间延时的话,具体作用是这样,当软件触发后(假设模式是软件触发),那么此时计数器开始计数,当到达延时0时,这时开启adc模块和通道“搭桥”的处理(这里是由于片内一般就一个adc,而外界通道可以多个,这里8个,那么当用那个通道为模拟量输入时候就连起来~“搭桥”)。到延时1结束,这个时候开始,adc开始工作转换(adc转换一个数据是要时间的),那么一旦计数器到了中断延时的时间,那么就可以在中断函数中进行相应的adc处理了,如读数。当然这里的配置需要和adc相结合,不然,在延时1后,adc可能不会做“转换”的工作的。。。
不好意思,我也才开始此款芯片,这只是我个人理解。。。
SIM_SCGC6 |= SIM_SCGC6_PDB_MASK ; // 使能时钟
SIM_SOPT7 &= ~(SIM_SOPT7_ADC1ALTTRGEN_MASK | // selects PDB not ALT trigger
SIM_SOPT7_ADC1PRETRGSEL_MASK |
SIM_SOPT7_ADC0ALTTRGEN_MASK | // selects PDB not ALT trigger
SIM_SOPT7_ADC0ALTTRGEN_MASK) ;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SIM_SOPT7 = SIM_SOPT7_ADC0TRGSEL(0); // applies only in case of ALT trigger, in which case
// PDB external pin input trigger for ADC
SIM_SOPT7 = SIM_SOPT7_ADC1TRGSEL(0); // same for both ADCs
// enable PDB, pdb counter clock = busclock / 20 , continous triggers, sw trigger , and use prescaler too
PDB0_SC = PDB_SC_CONT_MASK // Contintuous, rather than one-shot, mode
| PDB_SC_PDBEN_MASK // PDB enabled
| PDB_SC_PDBIE_MASK // PDB Interrupt Enable
| PDB_SC_PRESCALER(0x5) // Slow down the period of the PDB for testing
| PDB_SC_TRGSEL(0xf) // Trigger source is Software Trigger to be invoked in this file
| PDB_SC_MULT(2); // Multiplication factor 20 for the prescale divider for the counter clock
// the software trigger, PDB_SC_SWTRIG_MASK is not triggered at this time.
PDB0_IDLY = 0x0000; // need to trigger interrupt every counter reset which happens when modulus reached
PDB0_MOD = 0xffff; // largest period possible with the slections above, so slow you can see each conversion.
// channel 0 pretrigger 0 and 1 enabled and delayed
PDB0_CH0C1 = PDB_C1_EN(0x01)
| PDB_C1_TOS(0x01)
| PDB_C1_EN(0x02)
| PDB_C1_TOS(0x02) ;
PDB0_CH0DLY0 = ADC0_DLYA ;
PDB0_CH0DLY1 = ADC0_DLYB ;
/ channel 1 pretrigger 0 and 1 enabled and delayed
PDB0_CH1C1 = PDB_C1_EN(0x01)
| PDB_C1_TOS(0x01)
| PDB_C1_EN(0x02)
| PDB_C1_TOS(0x02) ;
PDB0_CH1DLY0 = ADC1_DLYA ;
PDB0_CH1DLY1 = ADC1_DLYB ;
PDB0_SC = PDB_SC_CONT_MASK // Contintuous, rather than one-shot, mode
| PDB_SC_PDBEN_MASK // PDB enabled
| PDB_SC_PDBIE_MASK // PDB Interrupt Enable
| PDB_SC_PRESCALER(0x5) // Slow down the period of the PDB for testing
| PDB_SC_TRGSEL(0xf) // Trigger source is Software Trigger to be invoked in this file
| PDB_SC_MULT(2) // Multiplication factor 20 for the prescale divider for the counter clock
| PDB_SC_LDOK_MASK; // Need to ok the loading or it will not load certain regsiters!
// the software trigger, PDB_SC_SWTRIG_MASK is not triggered at this time.
我对这段代码还理解的不太好,欢迎指导
|
|