MikroElektronika PIC Microcontrollers PIC16 Manuale Utente

Navigare online o scaricare Manuale Utente per Tavolini per PC/Workstation MikroElektronika PIC Microcontrollers PIC16. mikroElektronika PIC Microcontrollers PIC16 User`s manual Manuale Utente

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 172
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 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...
Vedere la pagina 0
1 2 3 4 5 6 ... 171 172

Sommario

Pagina 1 - MikroElektronika

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

Pagina 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

Pagina 3

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

Pagina 4

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

Pagina 5 - To readers note

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

Pagina 6 - C H A P T E R

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

Pagina 7

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

Pagina 8 - CODE EDITOR

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

Pagina 9 - Advanced Editor Features

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

Pagina 10 - Uncomment Icon

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

Pagina 11 - CODE EXPLORER

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

Pagina 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

Pagina 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

Pagina 14

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

Pagina 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

Pagina 16

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

Pagina 17

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

Pagina 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

Pagina 19 - Managing Source Files

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

Pagina 20

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

Pagina 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

Pagina 22 - DEBUGGER

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

Pagina 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

Pagina 24 - ERROR WINDOW

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

Pagina 25 - ASSEMBLY VIEW

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

Pagina 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

Pagina 27 - Chapter

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

Pagina 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

Pagina 29 - INTEGRATED TOOLS

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

Pagina 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.

Pagina 31 - KEYBOARD SHORTCUTS

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

Pagina 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

Pagina 33 - Reference

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

Pagina 34 - IDENTIFIERS

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

Pagina 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

Pagina 36 - DATA TYPES

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

Pagina 37

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

Pagina 38 - For example:

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

Pagina 39

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

Pagina 40 - Character Strings

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

Pagina 41 - CONSTANTS

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

Pagina 42

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

Pagina 43

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

Pagina 44 - VARIABLES

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

Pagina 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

Pagina 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

Pagina 47

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

Pagina 48 - COMMENTS

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

Pagina 49 - EXPRESSIONS

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

Pagina 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

Pagina 51 - DECLARATIONS AND STATEMENTS

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

Pagina 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

Pagina 53 - DIRECTIVES

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

Pagina 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

Pagina 55 - PROCEDURES AND FUNCTIONS

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

Pagina 56 - ' routine

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

Pagina 57

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

Pagina 58 - ' case end

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

Pagina 59

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

Pagina 60

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

Pagina 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

Pagina 62 - Output Generator

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

Pagina 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

Pagina 64

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

Pagina 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

Pagina 66

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

Pagina 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

Pagina 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

Pagina 69 - Example 3:

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

Pagina 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

Pagina 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

Pagina 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

Pagina 73

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

Pagina 74

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

Pagina 75

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

Pagina 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

Pagina 77

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

Pagina 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

Pagina 79

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

Pagina 80 - Runtime Behavior

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

Pagina 81 - Arithmetic Operators

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

Pagina 82

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

Pagina 83 - Specific

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

Pagina 84 - Boolean Operators

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

Pagina 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

Pagina 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

Pagina 87

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

Pagina 88

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

Pagina 89 - Expressions

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

Pagina 90

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

Pagina 91

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

Pagina 92 - CONDITIONAL STATEMENTS

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

Pagina 93 - Select Case Statement

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

Pagina 94

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

Pagina 95 - If Statement

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

Pagina 96 - Examples

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

Pagina 97

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

Pagina 98 - For Statement

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

Pagina 99

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

Pagina 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

Pagina 101 - While Statement

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

Pagina 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

Pagina 103 - PIC MCU SPECIFIC

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

Pagina 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

Pagina 105

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

Pagina 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

Pagina 107

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

Pagina 108

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

Pagina 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

Pagina 110 - BUILT-IN ROUTINES

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

Pagina 111

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

Pagina 112 - LIBRARY ROUTINES

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

Pagina 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

Pagina 114

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

Pagina 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

Pagina 116 - ADC Library

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

Pagina 117 - Figure (ADC HW connection)

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

Pagina 118 - CAN Library

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

Pagina 119

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

Pagina 120

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

Pagina 121

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

Pagina 122

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

Pagina 123

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

Pagina 124 - CAN_TX_MSG_FLAGS

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

Pagina 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

Pagina 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

Pagina 127

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

Pagina 128

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

Pagina 129 - Shielded pair, less

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

Pagina 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

Pagina 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

Pagina 132

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

Pagina 133

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

Pagina 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

Pagina 135

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

Pagina 136 - CAN Library Constants

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

Pagina 137

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

Pagina 138

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

Pagina 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

Pagina 140

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

Pagina 141

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

Pagina 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

Pagina 143

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

Pagina 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

Pagina 145 - EEPROM Library

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

Pagina 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

Pagina 147

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

Pagina 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

Pagina 149

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

Pagina 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

Pagina 151 - Commands

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

Pagina 152 - Figure: LCD HW connection

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

Pagina 153 - PWM Library

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

Pagina 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

Pagina 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

Pagina 156

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

Pagina 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

Pagina 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

Pagina 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

Pagina 160 - RS485 communication line

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

Pagina 161 - SPI Library

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

Pagina 162

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

Pagina 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

Pagina 164

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

Pagina 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

Pagina 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

Pagina 167

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

Pagina 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.

Pagina 169 - Numeric Formatting Routines

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

Pagina 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

Pagina 171 - Utilities

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

Pagina 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

Commenti su questo manuale

Nessun commento