I need some pointers/help in using IIC bus.
I'm using it to send data to a serial DAC (Max521), which is compatible with IIC. However, when I run my code I'm not convinced that it is outputting the correct wave forms...
The code is something like this:
for(;
{
init_IIC();
write_IIC();
}
void init_IIC(){
//Try Setting DDRJ
DDRJ_DDRJ6=1;
DDRJ_DDRJ7=1;
IBFD = 0x20; //Frequency divider
IBAD = 0x1F; //This is to set the slave address of the IIC -- Doesn't really matter ?
IBCR= 0xB0; //Enables, makes master, sets to transmit
}
void write_IIC() {
IBDR = 0x50; // Slave Address 0101 0000
while(IBSR_TCF ==0 ) {
asm(nop);
}
IBDR= 0x00; //DAC0
while(IBSR_TCF ==0 ) {
asm(nop);
}
IBDR = 0xFF;//Activate DAC full tilt
while(IBSR_TCF ==0 ) {
asm(nop);
}
IBCR = 0; //Stop Transmission.
}
Any Suggestions would be greatly appreciated. Thanks guys.