Product Specs
2.12 I2C Interface
There is a dedicated I2C communications interface on pins SCL and SDA. This interface bus is shared
with the accelerometer (Address 0x19) and temperature sensor (Address 0x48). There are 10kΩ pull-ups
on included on the module. The parameters of the I2C interface are shown in Table 3-6.
Table 3-6: I2C Parameters
Parameter
Value
SCL Pin
SCL
SDA PIN
SDA
Data Rates
100kHz & 400 kHz
Pull
-
ups (On Module)
10k
Ω
Unavailable Addresses
0x19, 0x48
An example of I2C communications is shown in Figure 3-16.
01 Class Temperature
2 Shared Function GetTemp() As Float
3 Dim sensor As I2c
4 sensor = I2c.Create(400000, Pin.SCL, Pin.SDA, 0x48)
5 Device.EnableTempSensor()
6 Thread.Sleep(40000) // See page 13 of the datasheet
7 Dim res As ListOfByte = sensor.Read(2)
8 Dim temp As Float = Float.NaN
9 If res <> Nothing Then
10
Dim part As
Float = res(1) >> 4
11
part = part
/ 16
12
temp = res(0).SignExtend() + part
13 End If
14 Device.DisableTempSensor()
15 Return temp
16 End Function
17 End Class
Figure 3-16: I2C mc-Script
2.13 PWM
The module contains a hardware PWM (Pulse Width Modulation) peripheral with the parameters specified
in Table 3-7. There are 3 PWM modules each with 4 channels per module. All channels using the same PWM
module MUST be the same frequency but their polarity and duty cycle may be changed.
The three things that define a PWM signal are the Pin, Period and Duty cycle. The pin specifies where
the PWM signal is sent to, the Period is the amount of time between the rising edges of the signal in
µSec and the duty cycle is the time that the pulse is active in µSec. So to create a pulse of 1Khz and a
duty cycle of 20% the user has to specify a 1000 µSec Period and a 200 µSec Duty Cycle. If the duty cycle
is 0 or negative the signal is always low and if the duty cycle is equal or larger than the period, the signal
is always high.
©2020 mc-Things Inc. Page | 14