max541为16bit DA芯片 为该芯片写的wince驱动集成进NK和动态加载效果不一样
1.集成进NK以后 我发现 max541本来应该输出1.25V的时候 却输出了1.8V的电压
2.使用DM动态加载时候 max541本来应该输出1.25V的时候 的确输出了1.25V的电压
这是为什么呢?
附代码:
void write_max541(unsigned long data)//16bit DA
{
RETAILMSG(TRUE, (TEXT("the num write into max541 is %x.\n"),data));
v_pIOPregs->GPGDAT=v_pIOPregs->GPGDAT&~(1<<1)|(1<<1);
delay_us(1);
v_pIOPregs->GPGDAT=v_pIOPregs->GPGDAT&~(1<<1);//set up a falling edge
write_spi1(data>>8);//input prefix num
RETAILMSG(TRUE, (TEXT("the prefix num write into max541 is %x.\r\n"),data>>8));
write_spi1(data&0xff);//input suffix num
RETAILMSG(TRUE, (TEXT("the suffix num write into max541 is %x.\r\n"),data&0xff));
v_pIOPregs->GPGDAT=v_pIOPregs->GPGDAT&~(1<<1);
delay_us(1);
v_pIOPregs->GPGDAT=v_pIOPregs->GPGDAT&~(1<<1)|(1<<1);//set up a rising edge
}
void write_spi1(unsigned char txdata)
{
v_pSPIPregs->SPTDAT1 = txdata;
RETAILMSG(TRUE, (TEXT("INFO:write_spi1 data (%ld).\n"), v_pSPIPregs->SPTDAT1));
while(!(v_pSPIPregs->SPSTA1 & 0x01== 0x01 ));
RETAILMSG(1,(TEXT("write_spi1 is over\n")));
}
max541用的2.5V参考电压 让它输出1.25V时 串口应该打印出0x7fff 串口确实打印出该数据 可是用万用表测出来的确是1.8V 这可就奇怪了 |