Lydia87
Newbie level 3
- Joined
- Dec 16, 2009
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- UK (Leeds)
- Activity points
- 1,306
Hi all,
Can anyone help to translate this code to mikroC Pro.
'''''''''''''''''''''''''''''''''''''''''''''''''''''
' CMPS03 I2C with serial LCD03 '
' example in PicBasic PRO '
' Reads a rotation as 0 - 255 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''
DEFINE OSC 8 ' 8mhz oscillator
DEFINE I2C_SLOW 1
DEFINE I2C_HOLD 1
DEFINE CHAR_PACING 102 ' 1 stop bit time to make 2 for LCD03
ver VAR BYTE ' To store software revision
w0 VAR word ' to store bearing data
b0 VAR w0.byte0 ' b0 is the low byte of word w0
b1 VAR w0.byte1 ' b1 is the high byte of word w0
b2 var byte ' Byte for storing decimal point of bearing
OUTPUT PORTC.1 ' RC1 tristate to output for lcd03
SEROUT PORTC.1,2,[12,4,1] ' Clear screen and hide cursor of LCD03
pause 1000
loop:
I2CREAD PORTC.4,PORTC.3,$C0,0,[ver] ' Read version number from CMPS03
SEROUT PORTC.1,2,[1,"Software v: ",#ver,13] ' Put it on the screen
pause 100
I2CREAD PORTC.4,PORTC.3,$C0,2,[b1,b0] ' Get the bearing as a value 0 - 3600
b2 = w0//10 ' Get the remainder of range this gives us our one decimal place of the range value
w0 = w0/10 ' Convert w0 into 0 - 360 range data
SEROUT PORTC.1,2,["bearing: ",#w0,".",#b2," "]' Display bearing data to the screen
goto loop
Best Wish
Lydia
Can anyone help to translate this code to mikroC Pro.
'''''''''''''''''''''''''''''''''''''''''''''''''''''
' CMPS03 I2C with serial LCD03 '
' example in PicBasic PRO '
' Reads a rotation as 0 - 255 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''
DEFINE OSC 8 ' 8mhz oscillator
DEFINE I2C_SLOW 1
DEFINE I2C_HOLD 1
DEFINE CHAR_PACING 102 ' 1 stop bit time to make 2 for LCD03
ver VAR BYTE ' To store software revision
w0 VAR word ' to store bearing data
b0 VAR w0.byte0 ' b0 is the low byte of word w0
b1 VAR w0.byte1 ' b1 is the high byte of word w0
b2 var byte ' Byte for storing decimal point of bearing
OUTPUT PORTC.1 ' RC1 tristate to output for lcd03
SEROUT PORTC.1,2,[12,4,1] ' Clear screen and hide cursor of LCD03
pause 1000
loop:
I2CREAD PORTC.4,PORTC.3,$C0,0,[ver] ' Read version number from CMPS03
SEROUT PORTC.1,2,[1,"Software v: ",#ver,13] ' Put it on the screen
pause 100
I2CREAD PORTC.4,PORTC.3,$C0,2,[b1,b0] ' Get the bearing as a value 0 - 3600
b2 = w0//10 ' Get the remainder of range this gives us our one decimal place of the range value
w0 = w0/10 ' Convert w0 into 0 - 360 range data
SEROUT PORTC.1,2,["bearing: ",#w0,".",#b2," "]' Display bearing data to the screen
goto loop
Best Wish
Lydia