Hello.
I have problem with SPI. Maybe mistake is my, maybe it's a bug.
I want produced DAC volt and DAC current with MCP4922. It's a 2 channel SPI DAC from Microchip.
But I found something strange.
Vol toutput is 2,5V and Current output is 0V with dac_Volt and dac_Current = 0.
With dac_Current I can adjust only Volt Output.
If I decrease dac_Current by one, output Volt is jump to 5V. If increase dac_Current, output is increase too.
With dac_Volt can't adjust anything.
I connect PIC MOSI with MOSI on MCP4922. Otherwise I lost comunication. And should not I connect MISO with MOSI and vice versa? Same problem with connection exist and with MCP3202.
This is real design.
I post Flowcode project, datasheet MCP4922 and Proteus project.
(Solved) Atmega16_MCP4922 problem
-
- Posts: 71
- Joined: Mon Dec 01, 2014 1:38 pm
- Location: Bulgaria
- Has thanked: 17 times
- Been thanked: 12 times
- Contact:
(Solved) Atmega16_MCP4922 problem
- Attachments
-
- MCP4922.pdf
- (3.62 MiB) Downloaded 189 times
-
- Proteus_Atmega16_MCP4922.rar
- (17.49 KiB) Downloaded 191 times
-
- Atmega_16_MCP4922.fcfx
- (22.67 KiB) Downloaded 195 times
Last edited by maharadga on Sat Jun 16, 2018 5:00 pm, edited 1 time in total.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Atmega16_MCP4922 problem
Hello,
MOSI = Master Out (SDO) Slave In (SDI)
MISO = Master In (SDI) Slave Out (SDO)
So the cross connection is done for you using the MOSI / MISO naming convention.
Looks like you are very close to a solution. This line of code may be the problem.
Try adding brackets to ensure the maths is correct.
Same for the Current channel.
Let us know how you get on.
MOSI should go to MOSI and MISO should go to MISO.I connect PIC MOSI with MOSI on MCP4922.
MOSI = Master Out (SDO) Slave In (SDI)
MISO = Master In (SDI) Slave Out (SDO)
So the cross connection is done for you using the MOSI / MISO naming convention.
Looks like you are very close to a solution. This line of code may be the problem.
Code: Select all
send_Volt = dac_Volt | 0x7 << 12
Code: Select all
send_Volt = dac_Volt | (0x7 << 12)
Let us know how you get on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 71
- Joined: Mon Dec 01, 2014 1:38 pm
- Location: Bulgaria
- Has thanked: 17 times
- Been thanked: 12 times
- Contact:
Re: Atmega16_MCP4922 problem
Hello, Benj.
I found out about the connections.
I add brackets, like you say, but result is the same.
I found out about the connections.
I add brackets, like you say, but result is the same.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Atmega16_MCP4922 problem
Have you wired up the external Latch pin and Enable pin?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 71
- Joined: Mon Dec 01, 2014 1:38 pm
- Location: Bulgaria
- Has thanked: 17 times
- Been thanked: 12 times
- Contact:
Re: Atmega16_MCP4922 problem
Yes, LDAC pin is connected to GND. Output registers are updated immediately.
-
- Posts: 71
- Joined: Mon Dec 01, 2014 1:38 pm
- Location: Bulgaria
- Has thanked: 17 times
- Been thanked: 12 times
- Contact:
Re: Atmega16_MCP4922 problem
I changed in Properties "Clock polarity" to Idle High and problem was resolved.
This work in real chip.
Have a nice day.
This work in real chip.
Have a nice day.
- Attachments
-
- Atmega_16_MCP4922.fcfx
- (20.34 KiB) Downloaded 223 times