MikroElektronika PIC Microcontrollers PIC16 Manual do Utilizador

Consulte online ou descarregue Manual do Utilizador para Barebones PC/estação de trabalho MikroElektronika PIC Microcontrollers PIC16. mikroElektronika PIC Microcontrollers PIC16 User`s manual Manual do Utilizador

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 172
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 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...
Vista de página 0
1 2 3 4 5 6 ... 171 172

Resumo do Conteúdo

Página 1 - MikroElektronika

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

Página 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

Página 3

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

Página 4

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

Página 5 - To readers note

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

Página 6 - C H A P T E R

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

Página 7

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

Página 8 - CODE EDITOR

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

Página 9 - Advanced Editor Features

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

Página 10 - Uncomment Icon

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

Página 11 - CODE EXPLORER

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

Página 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

Página 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

Página 14

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

Página 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

Página 16

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

Página 17

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

Página 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

Página 19 - Managing Source Files

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

Página 20

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

Página 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

Página 22 - DEBUGGER

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

Página 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

Página 24 - ERROR WINDOW

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

Página 25 - ASSEMBLY VIEW

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

Página 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

Página 27 - Chapter

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

Página 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

Página 29 - INTEGRATED TOOLS

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

Página 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.

Página 31 - KEYBOARD SHORTCUTS

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

Página 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

Página 33 - Reference

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

Página 34 - IDENTIFIERS

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

Página 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

Página 36 - DATA TYPES

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

Página 37

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

Página 38 - For example:

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

Página 39

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

Página 40 - Character Strings

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

Página 41 - CONSTANTS

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

Página 42

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

Página 43

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

Página 44 - VARIABLES

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

Página 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

Página 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

Página 47

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

Página 48 - COMMENTS

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

Página 49 - EXPRESSIONS

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

Página 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

Página 51 - DECLARATIONS AND STATEMENTS

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

Página 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

Página 53 - DIRECTIVES

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

Página 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

Página 55 - PROCEDURES AND FUNCTIONS

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

Página 56 - ' routine

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

Página 57

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

Página 58 - ' case end

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

Página 59

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

Página 60

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

Página 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

Página 62 - Output Generator

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

Página 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

Página 64

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

Página 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

Página 66

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

Página 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

Página 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

Página 69 - Example 3:

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

Página 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

Página 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

Página 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

Página 73

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

Página 74

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

Página 75

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

Página 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

Página 77

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

Página 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

Página 79

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

Página 80 - Runtime Behavior

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

Página 81 - Arithmetic Operators

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

Página 82

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

Página 83 - Specific

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

Página 84 - Boolean Operators

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

Página 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

Página 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

Página 87

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

Página 88

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

Página 89 - Expressions

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

Página 90

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

Página 91

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

Página 92 - CONDITIONAL STATEMENTS

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

Página 93 - Select Case Statement

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

Página 94

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

Página 95 - If Statement

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

Página 96 - Examples

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

Página 97

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

Página 98 - For Statement

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

Página 99

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

Página 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

Página 101 - While Statement

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

Página 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

Página 103 - PIC MCU SPECIFIC

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

Página 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

Página 105

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

Página 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

Página 107

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

Página 108

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

Página 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

Página 110 - BUILT-IN ROUTINES

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

Página 111

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

Página 112 - LIBRARY ROUTINES

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

Página 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

Página 114

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

Página 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

Página 116 - ADC Library

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

Página 117 - Figure (ADC HW connection)

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

Página 118 - CAN Library

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

Página 119

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

Página 120

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

Página 121

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

Página 122

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

Página 123

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

Página 124 - CAN_TX_MSG_FLAGS

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

Página 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

Página 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

Página 127

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

Página 128

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

Página 129 - Shielded pair, less

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

Página 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

Página 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

Página 132

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

Página 133

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

Página 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

Página 135

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

Página 136 - CAN Library Constants

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

Página 137

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

Página 138

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

Página 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

Página 140

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

Página 141

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

Página 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

Página 143

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

Página 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

Página 145 - EEPROM Library

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

Página 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

Página 147

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

Página 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

Página 149

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

Página 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

Página 151 - Commands

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

Página 152 - Figure: LCD HW connection

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

Página 153 - PWM Library

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

Página 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

Página 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

Página 156

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

Página 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

Página 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

Página 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

Página 160 - RS485 communication line

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

Página 161 - SPI Library

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

Página 162

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

Página 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

Página 164

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

Página 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

Página 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

Página 167

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

Página 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.

Página 169 - Numeric Formatting Routines

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

Página 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

Página 171 - Utilities

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

Página 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

Comentários a estes Manuais

Sem comentários