User`s manual

mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
' ..continued
cont = true
' upon signal change on RB0 pin
while cont
' from logical 0 to 1
' proceed with program
cont = TestTaster
' execution
wend
data[0] = 0
CANInitialize( 1,1,3,3,1,aa)
' initialize CAN
CANSetOperationMode(CAN_MODE_CONFIG,TRUE)
' set CONFIG mode
ID = -1
CANSetMask(CAN_MASK_B1,ID,CAN_CONFIG_XTD_MSG)
' set all mask1 bits to ones
CANSetMask(CAN_MASK_B2,ID,CAN_CONFIG_XTD_MSG)
' set all mask2 bits to ones
CANSetFilter(CAN_FILTER_B1_F1,3,CAN_CONFIG_XTD_MSG)
' set id of filter B1_F1 to 3
CANSetOperationMode(CAN_MODE_NORMAL,TRUE)
' set NORMAL mode
portd = $FF
id = 12111
CANWrite(id,data,1,aa1)
' send message via CAN
while true
oldstate = 0
zr = CANRead(id , Data , lenn, aa2)
if (id = 3) and zr then
portd = $AA
portc = data[0]
' output data at portC
data[0] = data[0]+1
id = 12111
CANWrite(id,data,1,aa1)
' send incremented data back
if lenn = 2 then
' if msg contains two data bytes
portd = data[1]
' output second byte at portd
end if
end if
wend
end.
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
123
page