|
发表于 2011-5-25 01:43:37
|
显示全部楼层
"程序能不能用一个函数代替比如: "
why? do you want to incur the unnecessary overhead associated with the function call?
all you need to do is to write the value to the port where d0..7 are connected.
like
#define dac08_write(val) {DAC08_DATA_PORT = (val);}
if your _CS pin is permanently tied down, you just need
dac08_write(val); //output val on dac08
to write a value on the dac.
if your _CS pin is controlled by the mcu, you need to lower / raise it:
dac08_select(DAC08_CTRL_CS); //lower the cs pin
dac08_write(val); //output the value
dac08_deselect(DAC08_CTRL_CS); //raise the cs pin |
|