(Solved) MCP3202 and Atmega16 what I do wrong?

An area to discuss AVR and Arduino specific problems and examples

Moderator: Benj

maharadga
Posts: 57
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 12 times
Been thanked: 11 times
Contact:

(Solved) MCP3202 and Atmega16 what I do wrong?

Postby maharadga » Sun Apr 29, 2018 4:51 pm

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.
Attachments
Atmega_16_MCP3202.fcfx
(21.74 KiB) Downloaded 33 times
MCP3202.pdf
(410.23 KiB) Downloaded 35 times
Last edited by maharadga on Mon May 14, 2018 4:44 pm, edited 1 time in total.

User avatar
LeighM
Matrix Staff
Posts: 1844
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 429 times
Been thanked: 612 times
Contact:

Re: MCP3202 and Atmega16 what I do wrong?

Postby LeighM » Tue May 01, 2018 3:26 pm

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

maharadga
Posts: 57
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 12 times
Been thanked: 11 times
Contact:

Re: MCP3202 and Atmega16 what I do wrong?

Postby maharadga » Tue May 01, 2018 4:12 pm

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.
Attachments
MCP 3202.rar
(15.7 KiB) Downloaded 26 times
Atmega_16_MCP3202.fcfx
(22.05 KiB) Downloaded 28 times

maharadga
Posts: 57
Joined: Mon Dec 01, 2014 1:38 pm
Location: Bulgaria
Has thanked: 12 times
Been thanked: 11 times
Contact:

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

Postby maharadga » Mon May 14, 2018 4:50 pm

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.
Attachments
Atmega_16_MCP3202.fcfx
(14.17 KiB) Downloaded 32 times
These users thanked the author maharadga for the post (total 2):
kersing (Mon May 14, 2018 5:16 pm) • Benj (Mon May 14, 2018 5:48 pm)
Rating: 11.11%