MSP430 simulates IIC interface program

Publisher:lcn18560863680Latest update time:2016-02-26 Source: eefocusKeywords:MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1 Introduction
    MSP430 MCU ordinary II simulation IIC interface program example.

2-Program routine

   #include "MSP430x14x.h"

   //P3.2 SCL

   //P3.3 SDA

   #define SDA_1 P3OUT |= BIT3          //SDA = 1

   #define SDA_0 P3OUT &=~ BIT3         //SDA = 0

   #define SCL_1 P3OUT |= BIT2          //SCL = 1

   #define SCL_0 P3OUT &=~ BIT2         //SCL = 0

   # DIR_IN P3DIR &=~ BIT3; SDA_1  //I/O port is input

   #define DIR_OUT P3DIR |= BIT3         //I/0 port is output

   #define SDA_IN ((P3IN >> 3) & 0x01)   //Read SDA

   unsigned int a[50];

/
      {
       TempBit = 1;
      }
   else
     {
      TempBit = 0;
     }
      DIR_OUT;
      TempData = define (TempData << 1) | TempBit;
      SCL_0;
   }
   Delay(5);
   return(TempData);
  }
  
/) && (i < 255))    
     {
       i++;
     }
     DIR_OUT;
     SCL_0;
     Delay(5);
   }

/)
   {
     unsigned char HighData = 0
     ; unsigned char LowData = 0;
     unsigned int TempData = 0;
     Start();
   WriteByte(0xa0);
   ReceiveAck ()
   ; WriteByte(unit) ; ReceiveAck(); Start() ; WriteByte(0xa1); ReceiveAck(); LowData = ReadByte(); Acknowledge( ) ; HighData = ReadByte() ; Stop(); TempData = (HighData << 8) + LowData; 0; unsigned int TempData = 0; Start(); WriteByte(0xa0); ReceiveAck(); WriteByte(unit); ReceiveAck(); Start(); WriteByte(0xa1); ReceiveAck(); for (i=0; i<49; i++) { LowData = ReadByte(); Acknowledge(); HighData = ReadByte(); Acknowledge(); a[i]= (HighData << 8) + LowData; } LowData = ReadByte(); Acknowledge(); HighData = ReadByte(); Stop(); a[49] = (HighData << 8) + LowData; Delay(1000); } /, unsigned int WriteData) { unsigned char LowData = 0; unsigned char HighData = 0; LowData = (unsigned char)WriteData; HighData = (unsigned char)(WriteData >> 8); Start(); xa0); ReceiveAck(); WriteByte(unit); ReceiveAck(); WriteByte(LowData); ReceiveAck();
   
   
   
   
   
   
   
   
   
   
   
   


   
   
   
   
   
   
   
   
   
   
   
   
   
   
     
      
      
      
      
      
     
   
   
   
   
   
   
   


   
     
     
     
     
     
     
     
     
     
     
     
     WriteByte(HighData);
     ReceiveAck();
     Stop();
     Delay(2000);
    }
//******************************************************************************
Keywords:MSP430 Reference address:MSP430 simulates IIC interface program

Previous article:Msp430 read and write 24c512 program
Next article:Detailed explanation of MSP430 microcontroller low power control and system working mode

Recommended ReadingLatest update time:2024-11-16 21:35

Electric shaver system design based on MSP430x09x MCU
  1 Introduction to MSP430x09x   MSP430x09x is the first 0.9V operating voltage MCU in the MSP430 series. This series is powerful and can be easily applied to micro motor control, infrared transmission, power supply detection and other occasions. In addition, its 0.9V operating characteristics can be widely used in
[Microcontroller]
Electric shaver system design based on MSP430x09x MCU
Research on WDT in MSP430 MCU
Introduction Software reliability has always been a key issue. Anyone who uses software may experience computer crashes or program errors, and this also happens in embedded systems. Due to the limited anti-interference ability of single-chip microcomputers, instrumentation in industrial sites often crashes du
[Microcontroller]
Research on WDT in MSP430 MCU
MSP430 Tutorial 7: Introduction to the ports of MSP430 microcontroller
The ports of MSP430 are P1, P2, P3, P4, P5, P6, S and COM (different models contain different ports, such as MSP430X11X series only have P1 and P2 ports, while MSP430X4XX series contains all the above ports), which can be used directly for input/output. There are no special input/output instructions in the MSP430 syste
[Microcontroller]
MSP430 Series Micropower MCU Selection Guide [Chinese Version]
The MSP430 series of microcontrollers are a type of 16-bit ultra-low power mixed signal processor (Mixed Signal Processor) that Texas Instruments (TI) began to market in 1996. It is called a mixed signal processor mainly because it integrates many analog circuits, digital circuits and microprocessors on one chip to
[Analog Electronics]
MSP430 controls segment LCD
//****************************************************************************** //  MSP-FET430P430 Demo - LCD, Display "0123456" on SBLCDA4 LCD // //  Description: Displays "0123456" on SBLCDA4 LCD as used on 430 Day Watch //  board. //  ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
[Microcontroller]
MSP430 Learning Notes (Part 2)
4. C12 analog-to-digital conversion module 1. Test voltage generator All ADC and DAC modules require a reference signal, which is what we often call Vref+, Vref-. The ADC12 module of MSP430 has an internal reference power supply. The internal reference power supply is started by controlling the REFON signal and
[Microcontroller]
TV backlight 3D infrared signal transmission solution based on MSP430G2303
Liquid crystal (LCD) TVs have become popular in the home appliance consumer market, because LCD displays require backlights, and traditional CCFL backlights have been gradually replaced by LED backlights. In LED backlight solutions, an MCU is often required to control the LED Driver. At the same time, as the market sha
[Microcontroller]
TV backlight 3D infrared signal transmission solution based on MSP430G2303
msp430 watchdog settings
Watchdog Timer ( Watchdog Timer (WDT_A) is actually a special timer that can be used as a watchdog or a timer. The so-called watchdog function is to monitor whether the program runs away due to some interference or error. The principle is that when the time of the fault meets the specified timing, a non-masking inter
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号