I found a circuit that sends data from pic dsPIC30f2012 (that pic has a resolution of 16 bits) to a DAC 12 bits (MCP4822) . My question is if I can use the SPI Module of a pic 18f2550 of 8 bits to send data to the DAC 12 bits. Can I do that or I just have to have the other PIC.
I found a circuit that sends data from pic dsPIC30f2012 (that pic has a resolution of 16 bits) to a DAC 12 bits (MCP4822) . My question is if I can use the SPI Module of a pic 18f2550 of 8 bits to send data to the DAC 12 bits. Can I do that or I just have to have the other PIC.
Thanks for your reply. As far as I know, the SPI Module of the PIC 16F877A can just send one 8bit word per time. How would you send two words of 8 bits together?
Thanks for your reply. As far as I know, the SPI Module of the PIC 16F877A can just send one 8bit word per time. How would you send two words of 8 bits together?
16 bits register, send the high 8 bits first, low 8 bits second (or whatever way the device wants).
Code:
unsigned char CMD[2],ctrl; // bits 7-4 control bits in ctrl
unsigned int data; // 12 bit data
/* set ctrl config bits */
CMD[0] = (unsigned char) (((data & 0x0F00) >> 8)|ctrl);
CMD[1] = (unsigned char) (data & 0x00F0); // lose the last four bits for 8 bit ADC
The MCP4822 does not use dual byte mode so above mentioned suggestion will not work. When you send to the MCP4822 simply truncate the 4 LSB's. In other words, send 12 bits ignoring the last 4 LSB.
I need to send the 16 bits, the one of 4 bits of control will allow me to select OutA or OutB. The question is how would u send the 16 bits. The SPI module wont work since it just have 8 bits. Could u explain how would the PIC C code be?
The MCP4822 does not use dual byte mode so above mentioned suggestion will not work. When you send to the MCP4822 simply truncate the 4 LSB's. In other words, send 12 bits ignoring the last 4 LSB.
I need to send the 16 bits, the one of 4 bits of control will allow me to select OutA or OutB. The question is how would u send the 16 bits. The SPI module wont work since it just have 8 bits. Could u explain how would the PIC C code be?
Assert the chip Enable.
put byte 1 in the SSP register.
wait for the byte to leave.
put byte 2 in the SSP register.
wait for the byte to leave.
De-assert the Chip Enable.