AMS Renesas Sensor Board – SSP Configuration

I would like to thank Jesse Casman and Craig Oda from the Learn IoT Community for providing me with the Renesas IoT Fast Prototyping Kit. These guys have a great site going that focuses on IoT and Sensors and you really should take a look if you are interested in either sensors or IoT.

The IoT Fast Prototyping Kit comes with several PMOD sensors (PMOD is a particular way of wiring a connector, like an Ardunio Shield, see Digilent’s Website for more information). One of these sensors is the AMS Renesas Sensor Board which includes the following sensors:

  1. AMS iAQ-Core Indoor Air Quality Sensor
  2. AMS ENS210 Humidity and Temperature Sensor
  3. AMS AS3935 Lightning Sensor
  4. AMS TMD3782 Proximity Sensor

Each sensor will have it’s own page. This post will cover how to setup and configure the SSP to talk to each sensor. The full code for all sensors is on GitHub.

Sensor Board Basics

Each sensor on the AMS Renesas Sensor Board is connected through a shared Inter-Integrated Circuit (I2C) bus. For more background on I2C, please see the Wikipedia article.

Without going in much detail, I2C uses a master/slave configuration. The Renesas microcontroller is the master since it starts and controls all communication. Each sensor is a slave device. I2C is a two wire protocol. One wire is the clock (commonly called SCL for serial clock) and one wire is a shared data wire (called SDA for serial data).

Since the data line is a shared bus with the master and all slaves, only one device can be “talking” at once. Either the master or a single slave device. This is a half-duplex form of communication. Full-duplex are when there are dedicated transmit and receive lines like you see on UART, RS-485, SPI, etc.

DK-S7G2 Board Configuration

 

SW5-1: Off
SW5-2: Off
SW5-3: Off
SW5-4: On
SW5-5: On
SW5-6: On
SW5-7: On
SW5-8: Off

J105 (PMOD C Voltage Level): 3.3V

S101: All switches off

SSP Configuration

In the SSP Configuration tab, add a new Driver=>Connectivity->I2C Driver on r_sci_i2c. I also added a Timer Driver and a UART Driver so I could write out sensor values to the serial port of my computer. I also use a timer to control how often the serial port data is updated.

Once you’ve added an I2C Driver, click on the SCI Common box below it and enable Simple I2C Mode (r_sci_i2c). If you have also added a UART Driver, also enable Asychronous Mode (r_sci_uart). Since so much data is being output on the UART (there is a lot of data for all the sensors!) also change the UART baud rate to 921600 (or the fastest rate your USB to Serial converter allows). This greatly speeds up the time needed during the several printf calls.

Now comes the tricky part – you will need to figure out which SCI channel you want to use for both the UART (if enabled) and I2C. I am using the DK-S7G2 which has four PMOD connectors. I’ve plugged the AMS Renesas Sensor Board into PMOD C.

I had to dig into the schematic for the base DK-S7G2 board and find out how the pins are mapped to the PMOD connector then peek at the microcontroller datasheet to find out which SCI channel those pins corresponded too. To make matters a bit more difficult, the PMOD connectors in the schematic are named as if they are UART lines, not I2C lines.

So, I looked at the pinout of the AMS Renesas Sensor board.AMSSensorBoardPMODConnector.png

So, SDA is on pin 2 and SCL is on pin 3. Looking at the schematic for the DK-S7G2, pin 2 of the PMOD connector (called TXD) is connected to P1_1 and pin 3 of the PMOD connector (called RXD) is connected to P1_0.

PMODCConnector.png

So, the SCL line is on pin P100 of the microcontroller and SDA is on pin  P101. Poking around in the Renesas Datasheet for my microcontroller, I see that P100 and P101 connect to SCI0. Whew, lots of steps there!

Back in e2Sutdio, click on the I2C Driver and change the channel to 0. Then set the ICU interrupt priorities or Priority 14. In these tutorials I will not be using the I2C interrupts, but they must still be configured.

I am using PMOD A for the UART communications. This corresponds to SCI8. Again, configure the channel on the UART driver for channel 8.

Almost done!

For some reason, when configuring the UART driver, it will automatically configure the pins to use the SCI channel (using e2studio v5.2.1.016). It does not do this for the I2C driver. This might be a bug, but most likely, by default, pins P1_00 and P1_01 are already used by an external memory device.

Since we aren’t using the external memory, we can disable that module and configure the pins to for I2C.

Click on the Pins tab, expand the Peripherals, and expand SDHI_MMC and click on SD_MMC0. Under the Operation Mode drop down, set it to disabled.

Then expand the SCI0_2_4_6_8 and click on SCI0. Change the operation mode to Simple I2c (SDA/SCL), set RXD0_SCL0_MISO0 to P100 and TXD0_SDA0_MOSI0 to P101.

This tells the SCI0 peripheral which pins are for the SCL (P100) and SDA (P101).

The above steps will need to be performed each time you configure I2C. If you are using a different PMOD connector, or a different development board, find out which SCI channel the PMOD device connects to and follow the same steps but configure it for your SCI channel and pin assignments.

IMPORTANT

For some reason, the AMS iAQ-Core sensor on the AMS board does not work with the default pin configuration. You must follow the steps below.

Still in the Pins tab of the Synergy Configuration, expand Ports, then P1. Click on P100 and change drive capacity to Low and Output type to n-ch open drain.

Do the same for P101.

If you do not set both the drive capacity and output type, you will not be able to talk to the iAQ-Core sensor (but you can still talk to the others).

Now that we’ve configured the SSP, we can start writing the code to talk to the individual sensors.

  1. AMS iAQ-Core Indoor Air Quality Sensor
  2. AMS ENS210 Humidity and Temperature Sensor
  3. AMS AS3935 Lightning Sensor (Coming Soon)
  4. AMS TMD3782 Proximity Sensor (Coming Soon)

I will be writing follow up articles for each sensor. In the meantime, code is up at GitHub that does talk to each sensor and outputs values. If you want to get a jump start, please checkout the source code at https://github.com/lycannon/ajwrs/tree/master/amsRenesasSensorBoard.

Advertisements

3 thoughts on “AMS Renesas Sensor Board – SSP Configuration

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s