MikroElektronika PIC Microcontrollers PIC16 Manuel d'utilisateur

Naviguer en ligne ou télécharger Manuel d'utilisateur pour PC/postes de travail MikroElektronika PIC Microcontrollers PIC16. mikroElektronika PIC Microcontrollers PIC16 User`s manual Manuel d'utilisatio

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 172
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 0
mikroBASIC
Develop your applications quickly and easily with the world's
most intuitive Basic compiler for PIC Microcontrollers (families
PIC12, PIC16, and PIC18).
Highly sophisticated IDE provides the power you need with the
simplicity of a Windows based point-and-click environment.
With useful implemented tools, many practical code examples,
broad set of built-in routines, and a comprehensive Help,
mikroBasic makes a fast and reliable tool, which can satisfy
needs of experienced engineers and beginners alike.
Basic Compiler for Microchip PIC microcontrollers
MikroElektronika
Development tools - Books - Compilers
www.mikroelektronika.co.yu
Users
manual
making it simple...
Vue de la page 0
1 2 3 4 5 6 ... 171 172

Résumé du contenu

Page 1 - MikroElektronika

mikroBASICDevelop your applications quickly and easily with the world'smost intuitive Basic compiler for PIC Microcontrollers (familiesPIC12, PIC

Page 2 - Table of Contents

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersAlso, Code Editor has feature to comment or uncomment selected block of codeby simple cli

Page 3

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersSyntax of do..loop statement is:dostatement_1...statement_Nloop until expressionwhere exp

Page 4

Syntax of while statement is:while expression statement_0statement_1...statement_NwendExpression is tested first. If it returns True, all the followin

Page 5 - To readers note

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 6 - C H A P T E R

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers98mikroBASICMikroElektronika: Development tools - Books - CompilersIn order to get t

Page 7

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 8 - CODE EDITOR

For example, when handling the interrupts from TMR0(if no other interrupts are allowed):sub procedure interruptcounter = counter + 1TMR0 = 96INTCON =

Page 9 - Advanced Editor Features

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 10 - Uncomment Icon

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers102mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple

Page 11 - CODE EXPLORER

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 12 - CREATING FIRST PROJECT

Built-in andLibrary RoutinesMikroElektronika: Development tools - Books - CompilersC H A P T E R3mikroBasic provides a number of built-in and li

Page 13

Code Explorer is placed to the left of the main window by default, and gives clearview of every declared item in the source code. You can jump to decl

Page 14

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersmikroBasic compiler incorporates a set of built-in functions and procedures. Theyare prov

Page 15 - Debug Icon

SetBit(PORTB,2)' set PORTB bit RB2 to value 1ClearBit(PORTC,7)' clear PORTC bit RC7TestBit(PORTA,2)' returns 1 if PORTA bit RA2 is 1, a

Page 16

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersLibrary procedures and functions represent a set of routines. This collection offunctions

Page 17

1-wire library provides routines for communicating via 1-wire bus, for examplewith DS1820 digital thermometer.Note that oscillator frequency Fosc need

Page 18 - PROJECTS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersprogram onewiredim i as bytedim j1 as bytedim j2 as byte dim por1 as byte dim por2 as byt

Page 19 - Managing Source Files

Figure (example of DS1820 on portc, pin 2)mikroBASIC- Basic Compiler for Microchip PIC microcontrollers110mikroBASICMikroElektronika: Development to

Page 20

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersADC (Analog to Digital Converter) module is available with a number of PICMCU models. Lib

Page 21 - Compile and Link Source Code

program ADC_Testdim temp_res as wordmain:ADCON1 = $80' configure analog inputs and VrefTRISA = $ff' designate PORTA as inputTRISB = $3F&ap

Page 22 - DEBUGGER

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersCAN (Controller Area Network) module is available with a number of PIC MCUmodels. mikroBa

Page 23

sub procedure CANSetOperationMode(dim mode as byte, dim WAIT as byte)mode - Operation mode code can take any of predefined constant values (see the co

Page 24 - ERROR WINDOW

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 25 - ASSEMBLY VIEW

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 26 - STATISTICS

CAN must be in Configuration mode or else these values will be ignored. SJW value as defined in 18XXX8 datasheet (must be between 1 thru 4)BRP value

Page 27 - Chapter

mikroBASIC- Basic Compiler for Microchip PIC microcontrollerssub procedure CANSetFilter(dim CAN_FILTER as byte, dim val as longint,dim CAN_CONFIG_FLAG

Page 28 - Procedures (Details) Window

sub function CANwrite(dim id as longint, dim byref Data as byte[8],dim DataLen as byte, dim CAN_TX_MSG_FLAGS as byte) as byteCAN must be in Normal mod

Page 29 - INTEGRATED TOOLS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersYou need to be familiar with constants that are provided for use with CAN libraryroutines

Page 30

These constant values define flags related to reception of a CAN message. Therecould be more than one this flag ANDed together to form multiple flags.

Page 31 - KEYBOARD SHORTCUTS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersThese constant values define filter codes. Routine CANSetFilter() requires thiscode as on

Page 32

This code demonstrates use of CAN library routines:program CANdim aa as bytedim aa1 as bytedim lenn as bytedim aa2 as bytedim data as byte[8]dim id as

Page 33 - Reference

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers' ..continuedcont = true' upon signal change on RB0 pinwhile cont' fro

Page 34 - IDENTIFIERS

Example of interfacing CAN transceiver with MCU and busmikroBASIC- Basic Compiler for Microchip PIC microcontrollers124mikroBASICMikroElektronika: De

Page 35 - KEYWORDS

After you have set up your project, select OK push button in New Project Wizarddialog box. mikroBasic will create project for you and automatically op

Page 36 - DATA TYPES

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersSPI (Serial Peripheral Interface) module is available with a number of PIC MCUmodels. Set

Page 37

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers126mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple

Page 38 - For example:

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 39

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers128mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple

Page 40 - Character Strings

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 41 - CONSTANTS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers130mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple

Page 42

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersYou need to be familiar with constants that are provided for use with CANSPIlibrary routi

Page 43

'..continuedaa1 = CAN_TX_PRIORITY_BITS andCAN_TX_FRAME_BIT andCAN_TX_RTR_BIT' prepare flags for CANSPIwrite functionCANSPIInitialize( 1,2,3,

Page 44 - VARIABLES

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersExample of interfacing CAN transceiver MCP2551 and MCP2510 with MCUand busMikroElektronik

Page 45 - Additional

Compact Flash Library provides routines for accessing data on Compact Flashcard (abbrev. CF further in text). CF cards are widely used memory elements

Page 46 - ' beginning of a module

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersIn this configuration, LED will emit light when voltage on pin is high (5V), andwill be o

Page 47

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 48 - COMMENTS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers136mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple

Page 49 - EXPRESSIONS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 50

This code demonstrates use of CF library procedures and functions.program CompactFlashdim i as worddim temp as longintdim k as longintmain:TRISC = 0&a

Page 51 - DECLARATIONS AND STATEMENTS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersFigure: Pin diagram of Compact Flash memory cardMikroElektronika: Development tools -

Page 52 - Statements

EEPROM data memory is available with a number of PIC MCU models. Set oflibrary procedures and functions is listed below to provide you comfortable wor

Page 53 - DIRECTIVES

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersI2C (Inter Integrated Circuit) full master MSSP (Master Synchronous Serial Port)module is

Page 54 - ' example for P16F877A

After configuring the I2C master mode, you have the following functions and pro-cedures at your disposal:sub function I2C_start as byteDetermines if I

Page 55 - PROCEDURES AND FUNCTIONS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers' Example of communication with 24c02 EEPROMprogram BasicI2cdim EE_adr as bytedim EE

Page 56 - ' routine

Figure: I2C interfacing EEPROM 24C04 to PIC MCUmikroBASIC- Basic Compiler for Microchip PIC microcontrollers144mikroBASICMikroElektronika: Developmen

Page 57

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers10mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 58 - ' case end

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersmikroBasic provides a set of library procedures and functions for communicatingwith commo

Page 59

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers146mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple

Page 60

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersprogram lcd18dim text as char[16]main:TRISB = 0' designate portb as outputLcd_Init(P

Page 61 - Main Unit File

CCP (Capture/ Compare/ PWM) module is available with a number of PIC MCUmodels. Set of library procedures and functions is listed below to provide com

Page 62 - Output Generator

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersThis code demonstrates use of PWM library procedures and functions. If pin RC2is connecte

Page 63 - SCOPE (IDENTIFIER VISIBILITY)

RS485 is a multipoint communication which allows multiple devices to be con-nected to a single signal cable. mikroBasic provides a set of library rout

Page 64

mikroBASIC- Basic Compiler for Microchip PIC microcontrollerssub procedure RS485master_initUSART needs to be initialized (USART_init) NoneInitializes

Page 65 - PROGRAM ORGANIZATION

sub procedure RS485master_write(dim byref data as byte[2],dim datalen as byte, dim address as byte)MCU must be initialized as Master in 485 communicat

Page 66

mikroBASIC- Basic Compiler for Microchip PIC microcontrollerssub procedure RS485slave_write(dim byref data as byte[2],dim datalen as byte)MCU must be

Page 67 - TYPE CONVERSION

program pr485dim dat as byte[8]' buffer for receiving/sending messagesdim i as bytedim j as bytesub procedure interruptif TestBit(RCSTA,OERR) = 1

Page 68 - Example 1:

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersWe will use the Step Over option (Run > Step Over or F8) to execute the currentprogram

Page 69 - Example 3:

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersFigure: Example of interfacing PC to PIC MCU via RS485 busMikroElektronika: Development

Page 70 - ' B becomes $00ff

SPI (Serial Peripheral Interface) module is available with a number of PIC MCUmodels. Set of library procedures and functions is listed below to provi

Page 71 - ' C becomes 213

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersExample:SPI_init(Master_OSC_div4, Data_SAMPLE_MIDDLE,LK_Idle_LOW,LOW_2_HIGH)This will set

Page 72 - 1 1 1 10000

Parameter lth_htl determines transmit edge for data. It can have the following val-ues:In order to keep this working, you shouldn't override the

Page 73

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersThe folowing code demonstrates how to use SPI library procedures and functions.Same examp

Page 74

Figure: Example of interfacing MAX7219 with PIC MCU via SPImikroBASIC- Basic Compiler for Microchip PIC microcontrollers160mikroBASICMikroElektronika:

Page 75

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersUSART (Universal Synchronous Asynchronous Receiver Transmitter) hardwaremodule is availab

Page 76

sub procedure USART_Init(const Baud_Rate)Parameter Baud_rate is the desired baud rate;Example:USART_init(2400)This will initialize PIC MCU USART hardw

Page 77

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersprogram RS232comdim Received_byte as bytemain:USART_init(2400)' initialize USART mo

Page 78 - OPERATORS

These routines convert byte, short, word, and integer to string. You can get textrepresentation of numerical value by passing it to one of the routine

Page 79

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers12mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 80 - Runtime Behavior

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersThe following code demonstrates use of library procedure ShortToStr. Exampleprints the co

Page 81 - Arithmetic Operators

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers166mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple

Page 82

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 83 - Specific

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 84 - Boolean Operators

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers14mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 85 - Logical (Bitwise) Operators

CHAPTER 1 mikroBasic IDELearn all about our advanced integrated environment. Create projects, debug your code, view statistics, and much more. CHAPTER

Page 86 - ' Bb becomes $70f4

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMake sure that window containing the file you want to print is the active window. Select

Page 87

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers16mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 88

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 89 - Expressions

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers18mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 90

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 91

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers20mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 92 - CONDITIONAL STATEMENTS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 93 - Select Case Statement

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersChapter 1.Integrated Development Environment - IDE22mikroBASICMikroElektronika: Develop

Page 94

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersProcedures (Details) WindowDisplays complete call tree, along with details for each proce

Page 95 - If Statement

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers24mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 96 - Examples

CHAPTER 1: mikroBasic IDE 1Quick Overview 1Code Editor 3Basic Editor Features 3Advanced Editor Features 4Code Explorer 6Creating First Project 7

Page 97

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers7 Segment Display Decoder7seg Display Decoder is a convenient visual panel which returns

Page 98 - For Statement

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers26mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 99

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersBasic Editor shortcutsF3 Find, Find NextCTRL+A Select AllCTRL+C CopyCTRL+F Fin

Page 100 - Do..Loop Until Statement

mikroBasic ReferenceMikroElektronika: Development tools - Books - CompilersC H A P T E R2‘Why Basic?’, you may wonder. Well, the answer is simpl

Page 101 - While Statement

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersIdentifiers are names used for referencing the stored values, such as variables andconsta

Page 102 - ASM Statement

The following keywords (reserved words) cannot be redefined or used as identi-fiers.In mikroBasic, all SFR (Special Function Registers) are defined as

Page 103 - PIC MCU SPECIFIC

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersType determines the allowed range of values for variable, and which operationsmay be perf

Page 104

Array is a set of data stored in consecutive memory locations. Defining an arrayand manipulating its elements is simple. Elements of array are always

Page 105

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersFor example:dim size as longint[10]occupies 40 RAM locations (bytes).program Array_testdi

Page 106 - COMPILER ERROR MESSAGES

String represents a sequence of characters. String type is similar to array, but canhold only characters.dim M_name as string[16]dim Start_message as

Page 107

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersAssignment And Implicit Conversion 65Implicit Conversion And Legal Expressions 69Operat

Page 108

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersNumeric constants can be represented in decimal, binary, or hexadecimal numbersystem.In d

Page 109 - Built-in and

Constant is data whose value cannot be changed during the runtime. Every con-stant is declared under unique name which must be a valid identifier. It

Page 110 - BUILT-IN ROUTINES

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersconst MaxAllowed = 234const K_a = -32766const Max = 1000if teA > Max then teA = teA -

Page 111

Symbol makes possible to replace expression with a single identifier alias. Use ofsymbols increases the reusability and flexibility of code.BASIC synt

Page 112 - LIBRARY ROUTINES

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 113 - 1-Wire Library

mikroBasic recycles local variable memory space - local variables declared in dif-ferent functions and procedures share same memory space, if possible

Page 114

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersprogram TRIALinclude "other.pbas"' You can declare variables in the progra

Page 115 - PIC16F877

Any valid variable can be used after it has been declared:tA = 36' assign new value to the existing variabletC = tA + tB' perform any kind o

Page 116 - ADC Library

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 117 - Figure (ADC HW connection)

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers44mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 118 - CAN Library

DISCLAIMER:The mikroBASIC compiler and this manual are owned by MikroElektronika and is protectedby copyright law and international copyright treaty.

Page 119

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersYou cannot mix signed and unsigned data types in expressions with arithmetic orlogical op

Page 120

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers46mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 121

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersStatements define algorithmic actions within a program. Simple statements - likeassignmen

Page 122

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers48mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 123

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersWe recommend careful use of absolute directive, because you may overlap twovariables by m

Page 124 - CAN_TX_MSG_FLAGS

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersmikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple...

Page 125 - CAN_MASK

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersThis means that the procedure callpr1_procedure(tA, tB, tC, tD)passes tA and tB by the va

Page 126 - CAN_CONFIG_FLAGS

In mikroBasic, use the keyword Result to assign the return value of a function. Example:dim locS as wordlocS = par1 + par2Result = locSend subAs funct

Page 127

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 128

sub program Stack_overflowsub procedure interruptnopend subsub procedure proc0nopend subsub procedure proc1proc0end subsub procedure proc2proc1end sub

Page 129 - Shielded pair, less

mikroBasic IDEMikroElektronika: Development tools - Books - CompilersmikroBasic is a Windows-based Integrated Development Environment, and is mu

Page 130 - CANSPI Library

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersEach project consists of a single project file, and one or more module files. Tobuild a p

Page 131

mikroBasic variables defined at the beginning of the module are global hiddenvariables. When you declare an identifier at the beginning of a module, y

Page 132

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 133

Scope, or identifier visibility, determines if identifier can be referenced in certainpart of the program code. Location of identifier declaration in

Page 134

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersFor example, in a function declaration:sub function Com(dim R as byte) as bytedim B as ch

Page 135

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers60mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 136 - CAN Library Constants

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersOrganization of other modules should have the following form:module unit_name' unit

Page 137

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers62mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 138

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersSpecial case is conversion between signed and unsigned. It is important to under-stand th

Page 139 - Compact Flash Library

Example 2:Explicit conversion can also be used when you are sure which type you want toconvert expression to. Consider the following lines:dim tA as b

Page 140

Code Editor features adjustable Syntax Highlighting, Code Assistant, ParametersAssistant, Auto Correct for common typos, and Code Templates. Code brow

Page 141

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 142

For signed types :dim B_ as integerdim A_ as short...A_ = -10B_ = A_ ' B becomes -10In hex representation, this means that the higher byte is

Page 143

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersIn order to fully understand this, we should recollect the data types.Data type determine

Page 144 - Compact Flash Card

As already stated, destination will store the correct value only if it can properlyrepresent the result of the expression (that is, the result fits in

Page 145 - EEPROM Library

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 146 - I2C Library

- If one operand is byte and another is word, byte is converted in word.- If one operand is short and another is integer, short is converted to intege

Page 147

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersr = expressionRefer to chapter Assignment and Implicit Conversion for details.When adding

Page 148

if A > B then ...if A > 47 then ...if A + B > A ...First, compiler evaluates the expression on the left. During runtime, result is storedin a

Page 149

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersThere are three types of operators in mikroPascal:Arithmetic OperatorsLogical (Bitwise) O

Page 150 - LCD Library

You cannot mix signed and unsigned data types in expressions with arithmetic orlogical operators. If you need to combine signed with unsigned, you wil

Page 151 - Commands

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersMikroElektronika: Development tools - Books - CompilersmikroBASICmaking it simple..

Page 152 - Figure: LCD HW connection

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersNotes for Relation OperatorsComparing variable or constant to variable or constant will a

Page 153 - PWM Library

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers76mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple.

Page 154 - Figure: PWM demonstration

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersIf number is converted from less complex to more complex data type, upper bytesare filled

Page 155 - RS485 Library

Unary arithmetic operators can be used to change sign of variables:a = 3b = -a' assign value -3 to bPIC microcontrollers are optimized to work wi

Page 156

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersBoolean operators are not true operators, because there is no boolean data typedefined in

Page 157

<< : shift left the operand for a number of bit places specified in the right operand(must be positive and less then 255).>> : shift right

Page 158 - RS485slave_write

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersIf number is converted from less complex to more complex data type, upper byteis filled w

Page 159

main:Sbb = $OFF0Saa = $0aSbb = Sbb and Sa ' Bb becomes $0000end.In this case, Sa is treated as an integer with the upper byte equal to $00 (thi

Page 160 - RS485 communication line

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers' You cannot mix signed and unsigned data types in' expressions with logical o

Page 161 - SPI Library

Relation operators (Comparison Operators) are commonly used in conditional andloop statements to control the program flow.In general case:Expression1

Page 162

mikroBASIC- Basic Compiler for Microchip PIC microcontrollers4mikroBASICMikroElektronika: Development tools - Books - Compilersmaking it simple..

Page 163 - Value Meaning

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersIf one operand is byte and another is word, byte is converted in word.If one operand is s

Page 164

Comparing variables and constants always produces the correct results regardlessof the operands' type.if A > B then ...if A > 47 then ...if

Page 165 - 8. 8. 8. 8. 8. 8. 8. 8

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersConditional statements control which part(s) of the program will be executed,depending on

Page 166 - USART Library

Select Case statement is used for selecting one of several available branches in theprogram course. It consists of a selector variable as a switch con

Page 167

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersselect case Wcase 0B = 1PORTB = Bcase 1A = 1PORTA = A case elsePORTB = 0end selec

Page 168 - Figure: RS232 HW connection

There are two forms of if statement:Syntax of if..then statement is:if expression then statementsend ifwhere expression returns a True or False value.

Page 169 - Numeric Formatting Routines

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersCompiler treats the construction like this:if expression1 then [ if expression2 thenstate

Page 170

Loops are a specific way to control the program flow. By using loops, you canexecute a sequence of statements repeatedly, with a control condition or

Page 171 - Utilities

mikroBASIC- Basic Compiler for Microchip PIC microcontrollersFor statement requires you to specify the number of iterations you want the loopto go thr

Page 172

Here is a simple example of a for loop used for emitting hex code on PORTB for7-segment display with common cathode. Nine digits will be printed with

Commentaires sur ces manuels

Pas de commentaire