MikroElektronika PIC Microcontrollers PIC16 Bedienungsanleitung

Stöbern Sie online oder laden Sie Bedienungsanleitung nach PC / Workstation Barebones MikroElektronika PIC Microcontrollers PIC16 herunter. mikroElektronika PIC Microcontrollers PIC16 User`s manual Benutzerhandbuch

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 172
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 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...
Seitenansicht 0
1 2 3 4 5 6 ... 171 172

Inhaltsverzeichnis

Seite 1 - MikroElektronika

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

Seite 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

Seite 3

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

Seite 4

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

Seite 5 - To readers note

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

Seite 6 - C H A P T E R

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

Seite 7

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

Seite 8 - CODE EDITOR

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

Seite 9 - Advanced Editor Features

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

Seite 10 - Uncomment Icon

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

Seite 11 - CODE EXPLORER

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

Seite 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

Seite 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

Seite 14

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

Seite 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

Seite 16

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

Seite 17

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

Seite 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

Seite 19 - Managing Source Files

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

Seite 20

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

Seite 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

Seite 22 - DEBUGGER

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

Seite 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

Seite 24 - ERROR WINDOW

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

Seite 25 - ASSEMBLY VIEW

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

Seite 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

Seite 27 - Chapter

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

Seite 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

Seite 29 - INTEGRATED TOOLS

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

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

Seite 31 - KEYBOARD SHORTCUTS

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

Seite 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

Seite 33 - Reference

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

Seite 34 - IDENTIFIERS

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

Seite 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

Seite 36 - DATA TYPES

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

Seite 37

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

Seite 38 - For example:

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

Seite 39

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

Seite 40 - Character Strings

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

Seite 41 - CONSTANTS

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

Seite 42

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

Seite 43

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

Seite 44 - VARIABLES

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

Seite 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

Seite 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

Seite 47

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

Seite 48 - COMMENTS

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

Seite 49 - EXPRESSIONS

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

Seite 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

Seite 51 - DECLARATIONS AND STATEMENTS

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

Seite 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

Seite 53 - DIRECTIVES

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

Seite 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

Seite 55 - PROCEDURES AND FUNCTIONS

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

Seite 56 - ' routine

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

Seite 57

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

Seite 58 - ' case end

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

Seite 59

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

Seite 60

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

Seite 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

Seite 62 - Output Generator

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

Seite 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

Seite 64

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

Seite 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

Seite 66

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

Seite 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

Seite 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

Seite 69 - Example 3:

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

Seite 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

Seite 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

Seite 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

Seite 73

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

Seite 74

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

Seite 75

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

Seite 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

Seite 77

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

Seite 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

Seite 79

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

Seite 80 - Runtime Behavior

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

Seite 81 - Arithmetic Operators

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

Seite 82

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

Seite 83 - Specific

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

Seite 84 - Boolean Operators

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

Seite 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

Seite 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

Seite 87

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

Seite 88

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

Seite 89 - Expressions

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

Seite 90

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

Seite 91

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

Seite 92 - CONDITIONAL STATEMENTS

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

Seite 93 - Select Case Statement

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

Seite 94

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

Seite 95 - If Statement

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

Seite 96 - Examples

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

Seite 97

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

Seite 98 - For Statement

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

Seite 99

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

Seite 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

Seite 101 - While Statement

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

Seite 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

Seite 103 - PIC MCU SPECIFIC

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

Seite 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

Seite 105

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

Seite 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

Seite 107

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

Seite 108

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

Seite 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

Seite 110 - BUILT-IN ROUTINES

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

Seite 111

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

Seite 112 - LIBRARY ROUTINES

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

Seite 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

Seite 114

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

Seite 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

Seite 116 - ADC Library

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

Seite 117 - Figure (ADC HW connection)

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

Seite 118 - CAN Library

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

Seite 119

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

Seite 120

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

Seite 121

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

Seite 122

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

Seite 123

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

Seite 124 - CAN_TX_MSG_FLAGS

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

Seite 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

Seite 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

Seite 127

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

Seite 128

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

Seite 129 - Shielded pair, less

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

Seite 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

Seite 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

Seite 132

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

Seite 133

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

Seite 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

Seite 135

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

Seite 136 - CAN Library Constants

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

Seite 137

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

Seite 138

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

Seite 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

Seite 140

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

Seite 141

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

Seite 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

Seite 143

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

Seite 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

Seite 145 - EEPROM Library

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

Seite 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

Seite 147

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

Seite 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

Seite 149

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

Seite 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

Seite 151 - Commands

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

Seite 152 - Figure: LCD HW connection

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

Seite 153 - PWM Library

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

Seite 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

Seite 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

Seite 156

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

Seite 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

Seite 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

Seite 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

Seite 160 - RS485 communication line

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

Seite 161 - SPI Library

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

Seite 162

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

Seite 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

Seite 164

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

Seite 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

Seite 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

Seite 167

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

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

Seite 169 - Numeric Formatting Routines

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

Seite 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

Seite 171 - Utilities

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

Seite 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

Kommentare zu diesen Handbüchern

Keine Kommentare