Page 1 of 1

(Solved) MCP3202 and Atmega16 what I do wrong?

Posted: Sun Apr 29, 2018 4:51 pm
by maharadga
Hello.
I try simple program with MCP3202 and Atmega16. I use SPI master.
Something I do wrong. I need some help with this.
I attach datasheet of MCP3202 and program. Maybe I not understanding SPI protokol?
I did not find any simple example for this.

Re: MCP3202 and Atmega16 what I do wrong?

Posted: Tue May 01, 2018 3:26 pm
by LeighM
Hi,
I think you would be better using the SPI CAL component (from Tools menu)
This component has a Master_Byte function that can send and receive data at the same time.
You will need to call this three times, sending data as on page 15 of the datasheet.
The last two bytes received will contain the conversion data.
Hope that helps,
Leigh

Re: MCP3202 and Atmega16 what I do wrong?

Posted: Tue May 01, 2018 4:12 pm
by maharadga
Thanks, LeighM for the answer.
I did as you said but all return data is 255.
Like before. In Proteus data is 0, in real chip 255.

Re: (Solved) MCP3202 and Atmega16 what I do wrong?

Posted: Mon May 14, 2018 4:50 pm
by maharadga
Problem is solved.
Reading MCP3202 and display on LCD Voltage from 0-5V in resolution 0.0012V.
This work in real chip.
Here is the program.
Have a nice day.