EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / after many research in your

after many research in your

|

Microcontroller › 8051 › Query about MCP3201 and 8051 communication – program is given › after many research in your

July 22, 2013 at 4:48 am #10174
shailesh
Participant

after many research in your program find out error……

 

 

remove rotation of bit in stored result at 15…..or make simple routine like

 

 

    //Routine for spi data read from mcp3201.   
unsigned int Get_ADC_Sample(void)    
{   
        unsigned int TempCount;   
        unsigned int Temp_Data=0;   
     
        SPI_CS_PIN=1;   
       
        for(TempCount=0;TempCount<16;TempCount++)                //counter for 16 databits   
        {   
            
                      SPI_CLK_PIN=0;
                        SPI_CS_PIN=0;                    
            SPI_CLK_PIN=1;
                   
                    if(TempCount!=15)   
           Temp_Data=Temp_Data<<1;  

                               
           
           if(SPI_DATA_PIN==1)
                            {Temp_Data = Temp_Data | 0x01;}  
                       
        }   
       
        SPI_CS_PIN=1;                                           //keep high when not doing the conversion.   
        Temp_Data &=0x0fff;                                     //mask upper 4 bits.   
        return Temp_Data;
                   
 }   
       
 

 

 

RSS Recent Posts

  • Getting into an LED bulb April 21, 2026
  • understanding of resonance in time domain April 21, 2026
  • Beginner Questions About CNC Machines – G-code, Control Systems & Accuracy April 21, 2026
  • A Must-Watch Video Showing Dangerous Construction of Cheap Lithium-Ion Cells April 21, 2026
  • S1MJ ? April 20, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise