I2C TM Slave Library Module (Interrupt-driven)

Similar documents
I2C TM Master Library Module (Polled)

ADCInt Library Module (Interrupt-driven)

ECAN TM (Polling) Module

DeviceNet Group 2 Slave Library Module

Basics of UART Communication

Section 16. Basic Sychronous Serial Port (BSSP)

Fredrick M. Cady. Assembly and С Programming forthefreescalehcs12 Microcontroller. шт.

DEVICE DRIVERS AND TERRUPTS SERVICE MECHANISM Lesson-15: Writing Device Driving ISRs in a System

Wireless communication for social robotics. Gu C. Department of Electrical & Computer Enginnering. National University of.

Microcontroller based Energy Recording and Data Transfer to Remote Computer in Distribution Network

Interrupts Peter Rounce - room 6.18

MPLAB Harmony Compatibility Worksheet

AN-895 APPLICATION NOTE

Microcontroller basics

Emulating Dual SPI Using FlexIO

GPS Reader. Figure 1: RMC NEMA Tag Definition

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers

Interrupts Peter Rounce

MPLAB C18 C Compiler

Section 21. UART UART HIGHLIGHTS. This section of the manual contains the following major topics:

RFIC TX/RX Configuration

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

COMP2121: Microprocessors and Interfacing

PART - B (Answer all five units, 5 X 10 = 50 Marks)

Welcome to this presentation of the STM32 direct memory access controller (DMA). It covers the main features of this module, which is widely used to

ECE 354 Introduction to Lab 1. February 5 th, 2003

3. (a) Explain the steps involved in the Interfacing of an I/O device (b) Explain various methods of interfacing of I/O devices.

RL78 Serial interfaces

DISCONTINUED. SPI Communication with AMT bit Absolute Encoder

Hello, and welcome to this presentation of the STM32 I²C interface. It covers the main features of this communication interface, which is widely used

In the HEW, open a new project by selecting New workspace from the main menu.

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation

FULL DUPLEX BIDIRECTIONAL UART COMMUNICATION BETWEEN PIC MICROCONTROLLERS

Microtronix Avalon I 2 C

Serial I-O for Dinesh K. Sharma Electrical Engineering Department I.I.T. Bombay Mumbai (version 14/10/07)

Processor Register Set of M16C

Microprocessors and Interfacng. Question bank

Tech Spec for SDXC Host Controller

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

EC 6504 MICROPROCESSOR AND MICROCONTROLLER

Hello, and welcome to this presentation of the STM32 Low Power Universal Asynchronous Receiver/Transmitter interface. It covers the main features of

RX Family, RL78 Family

EFM32 Series 0: DMA (ARM PrimeCell µdma PL230)

MICROPROCESSORS & MICRO CONTROLLER COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK

Integrated Device Technology, Inc Stender Way, Santa Clara, CA Phone #: (408) Fax #: (408) Errata Notification

PIC32 Family Reference Manual

Two Wire Interface (TWI) also commonly called I2C

VORAGO VA108x0 I 2 C programming application note

Using FlexIO to emulate communications and timing peripherals

EE458 - Embedded Systems Exceptions and Interrupts

PIC16C7X 11.0 SYNCHRONOUS SERIAL PORT (SSP) MODULE SSP Module Overview. Applicable Devices

Hello, and welcome to this presentation of the STM32 Universal Synchronous/Asynchronous Receiver/Transmitter Interface. It covers the main features

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

CAN Protocol Implementation

PIC24 Bully Bootloader Documentation

BLE 1.4 SPI Driver Design Version 1.x (Draft)

Section 21. Addressable USART

Implementation of MCU Invariant I2C Slave Driver Using Bit Banging

Department of Computer Science and Engineering

Section 31. DMA Controller

Lab 8 (ETH): Control Area Network

Typical modules include interfaces to ARINC-429, ARINC-561, ARINC-629 and RS-422. Each module supports up to 8 Rx or 8Tx channels.

PIC Serial Peripheral Interface (SPI) to Digital Pot

RX Family APPLICATION NOTE. I 2 C Bus Interface (RIIC) Module Using Firmware Integration Technology. Introduction. Target Device.

Course Introduction. Purpose: Objectives: Content: 27 pages 4 questions. Learning Time: 20 minutes

How to program the Fast Amplifiers

PIC Microcontroller Introduction

Embedded Systems and Software. Serial Communication

AN Multifunction Serial Interface of FM MCU. Contents. 1 Introduction

Embedded Systems and Software

MPLAB SIM. MPLAB IDE Software Simulation Engine Microchip Technology Incorporated MPLAB SIM Software Simulation Engine

ET-PIC 24 WEB-V1. o Central Processing Unit (CPU) o System. o nanowatt Power Managed Modes. o Analog Features

OUTLINE. SPI Theory SPI Implementation STM32F0 SPI Resources System Overview Registers SPI Application Initialization Interface Examples

Programming in the MAXQ environment

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

An SPI interface for the 65(C)02 family of microprocessors

Interrupts and Serial Communication on the PIC18F8520

For reference only Refer to the latest documents for details

Getting acquainted with the development tools June 27, 2006 ELE492 Embedded System Design Exercise 1

8051 Serial Communication

GLOSSARY. VisualDSP++ Kernel (VDK) User s Guide B-1

UNIT V MICRO CONTROLLER PROGRAMMING & APPLICATIONS TWO MARKS. 3.Give any two differences between microprocessor and micro controller.

MOS INTEGRATED CIRCUIT

Laboratory 5 Communication Interfaces

MICROPROCESSOR Architecture, Programming and Interfacing SUNIL MATHUR. Assistant Professor Maharaja Agrasen Institute of Technology Delhi

Section 21. Inter-Integrated Circuit (I 2 C )

MARIE: An Introduction to a Simple Computer

INTRODUCTION OF MICROPROCESSOR& INTERFACING DEVICES Introduction to Microprocessor Evolutions of Microprocessor

Outline GPIO SPI UART. Ref. PIC Family Reference Manual:

Section 21. UART UART HIGHLIGHTS. This section of the manual contains the following topics:

System Design Guide for Slave

CPCI-HPDI32ALT High-speed 64 Bit Parallel Digital I/O PCI Board 100 to 400 Mbytes/s Cable I/O with PCI-DMA engine

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

Maxim > Design Support > Technical Documents > Application Notes > Microcontrollers > APP 4465

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

AN-1159 APPLICATION NOTE

embos Real Time Operating System CPU & Compiler specifics for PIC18 core using C18 compiler and MPLAB

Designing with Nios II Processor for Hardware Engineers

427 Class Notes Lab2: Real-Time Clock Lab

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

Transcription:

I2C TM Slave Library Module (Interrupt-driven) 1. Introduction... 2 2. Module Features...2 3. List of Component Modules... 3 4. Using the Library Module in a Project... 3 5. List of Shared Parameters... 4 Shared Data Bytes... 4 Shared Functions... 4 Shared Macros...4 6. Functions... 5 7. Macros... 7 8. Error and Status Flags... 8 I2C Slave Library Module (Interrupt-driven) Page 1

1. Introduction The I2CSInt is a general-purpose library module. It configures the SSP/MSSP module in the Slave mode and helps in communicating with the the I2C TM Master. The module code is linkable and relocatable, which provides the user the facility to use it without modifications. It provides interrupt-based operation and has its own Tx/Rx buffer, which provides maximum benefit of parallel processing. By using this Module, one can write his application to interact with any of the I2C Master. The module allows the user to concentrate more on his application s development by providing these library functions. 2. Module Features It supports following features:- It provides simple and primitive functions to communicate with the I2C Master. User defined length of Tx/Rx Buffer. Interrupt driven transmission and reception. It provides error recovery option. It uses, user selectable Timer for this purpose. It generates Error flags on the occurrence of an error. All error conditions are passed through the I2CSIntStatus Register. I2C Slave Library Module (Interrupt-driven) Page 2

3. List of Component Modules I2CSInt.P16.ex.txt I2CSInt.P18.ex.txt I2CSInt.asm 16I2CSI.asm 18I2CSI.asm I2CSInt.inc P16xxx.inc P18xxx.inc This is an example file developed to demonstrate the use of the library functions for the PIC16 family. This is an example file developed to demonstrate the use of the library functions for the PIC18 family. This is the I2C Slave code implementation file. One needs to include this file in their project. This is the I2C Slave code implementation file for the PIC16 family. The I2CSInt.asm file will include this file if the PIC16 family processor is used. This is the I2C Slave code implementation file for the PIC18 family. The I2CSInt.asm file will include this file if the PIC18 family processor is used. This file contains the definitions of all the shared parameters and the macros. One needs to include this in the Assembly file where the library functions and the macros are called. This file takes care of the definitions of all the Extern Global parameters, so that one can directly call the library routines in their program. General purpose processor definition file for the PIC16 family General purpose processor definition file for the PIC18 family 4. Using the Library Module in a Project Please follow the steps below to use this library module in your project. 1. Use the Application Maestro to configure the module as required. 2. At the Generate Files step, save the output to the directory where your project code resides. 3. Launch MPLAB, and open the project s workspace. 4. Verify that the Microchip language tool suite is selected (Project>Select Language Toolsuite). 5. In the Workspace view, right-click on the Source Files node. Select the Add Files option. Select the file I2CSInt.asm and click OK. 6. Now right-click on the Linker Scripts node and select Add Files. Add the appropriate linker file (.lkr) for the project s target microcontroller. 7. Add any other files that the project may require. Save and close the project. 8. In your main source (assembler) file, add include directive at the head of the code listing to include the file I2CSInt.inc. By doing so, all files required to make the generated code work in your project will be included by reference when you build the project. 9. To use the module in your application, invoke the functions or the macros as needed. I2C Slave Library Module (Interrupt-driven) Page 3

5. List of Shared Parameters Shared Data Bytes vi2csintstatus It is the Error/Status register. The details of each bit of this register is explained in Section 8 Shared Functions I2CSIntInit I2CSIntPut I2CSIntGet I2CSIntISR I2CSIntDiscardRxBuf It is used for Synchronous Serial Port Initialization It initializes the Port according to the options opted through the Application Maestro. It is used for transmitting a byte on the I2C Bus. It is used for reading the received byte. It is called from interrupt handler. It transmits/receives data from Master and sets Error/Status flags accordingly. It is used for discarding the Rx Buffer contents. Shared Macros mi2csintdisable mseti2csinthighpriority mseti2csintlowpriority It disables the Synchronous Serial Port. It sets the interrupt priority of SSP as High. It sets the interrupt priority of SSP as Low. I2C Slave Library Module (Interrupt-driven) Page 4

6. Functions Function Pre-conditions I2CSIntInit TRIS bits of the SCL,SDA are to be made inputs and if Timer is used for error recovery, it has to be initialized for the required Time-out period. This function is used for initializing the MSSP/SSP module. It initializes the module according to the Application Maestro options. Application Maestro options Bank selection bits and W register are changed 1 level deep Function Pre-conditions I2CSIntPut The function I2CSIntInit should have been called. This function sends the byte in W Reg. over I2C bus or saves it in the Tx Buffer, to be sent later. 'W' Register. 'I2CSIntStatus' Register. I2CSIntStatus <I2CSTxBufFull> is set if Tx-Buffer becomes full. I2CSIntStatus <I2CSTxBufEmpty,I2CSTxBufUnderFlow> are cleared. Bank selection bits and W register are changed 1 level deep Function I2CSIntGet Pre-conditions The bit I2CSRxBufEmpty of the register I2CSIntStatus should be 0. This function reads the byte received. W Register and 'I2CSIntStatus' Register. W Register will have received Data. 'I2CSIntStatus <I2CSRxBufEmpty>' is set if Rx-Buffer becomes empty. 'I2CSIntStatus <I2CSRxBufFull,I2CSRxBufOverFlow>' are cleared. Bank selection bits and W register are changed 1 level deep I2C Slave Library Module (Interrupt-driven) Page 5

Function Pre-conditions I2CSIntISR Must be called from interrupt handler. If the SSP interrupt has occurred then, it transmits/receives data from Master, sets Error/Status flags accordingly, clears the Timer and enables the Timer interrupt. If Timer interrupt has occurred then, it disables SSP Module, releases the clock, re-enable the SSP Module and disables the timer interrupt. 'I2CSIntStatus' Register. I2CSIntStatus <I2CSTx> is set if Master wants to read from Slave. I2CSIntStatus <I2CSRxBufEmpty> is cleared if data is received from Master. I2CSIntStatus <I2CSRxBufFull> is set if Rx-Buffer becomes full. I2CSIntStatus <I2CSRxBufOverFlow> is set if a data byte is received when Rx-Buffer is full. I2CSIntStatus <I2CSTxBufFull> is cleared if data is sent to the Master. I2CSIntStatus <I2CSTxBufEmpty> is set if Tx-Buffer becomes empty. I2CSIntStatus <I2CSTxBufUnderFlow> is set if the Master wants to read a data byte when Tx-Buffer is empty. Bank selection bits and W register are changed 2 level deep Function Pre-conditions I2CSIntDiscardRxBuf This discards the received data bytes. 'I2CSIntStatus' Register. I2CSIntStatus <I2CSRxBufEmpty> is set. I2CSIntStatus <I2CSRxBufFull, I2CSRxBufOverFlow > are cleared. Bank selection bits are changed 1 level deep I2C Slave Library Module (Interrupt-driven) Page 6

7. Macros Macro mi2csintdisable Disables the SSP/BSSP/MSSP module. Bank selection bits are changed. Macro mseti2csinthighpriority (Valid only for PIC18 family devices). This sets the interrupt priority of SSP High. Bank selection bits are changed. Macro mseti2csintlowpriority (Valid only for PIC18 family devices). This sets the interrupt priority of SSP Low. Bank selection bits are changed. I2C Slave Library Module (Interrupt-driven) Page 7

8. Error and Status Flags All errors/statuses are set as a content of the I2CSIntStatus Register. The individual errors/ statuses are unique. Please refer the list below for the information. I2CSTx I2CSRxBufFull I2CSRxBufEmpty I2CSRxBufOverFlow I2CSTxBufEmpty I2CSTxBufFull I2CSTxBufUnderFlow This indicates that, the Master wants to read data bytes from this device. This indicates that, the Rx-Buffer is full.. This indicates that, the Rx-Buffer is empty. This indicates that, a byte of data has been received while the Rx-Buffer is full. This indicates that, the Tx-Buffer is empty. This indicates that, the Tx-Buffer is full.. This indicates that, a byte of data is demanded by the Master while the Tx-Buffer is empty. I2C Slave Library Module (Interrupt-driven) Page 8