I2C communication with Wire.h(ESP32) - i2c

I trying to connect with nitric oxide sensor over I2C bus. I'm using Wire.h library.
http://semeatech.com/uploads/SensorModule/7-Smart_EN-v1.0.pdf <- Aplication note
My code:
Wire.beginTransmission(0x0B);
Wire.write(0x00);
Wire.write(0x01);
byte err = Wire.endTransmission(false);
Wire.requestFrom(0x0B, 3);
while(Wire.available()){
//Read data
}
Sensor returns msb = 0, lsb = 0 and checkSum = 255
Am I doing something wrong with I2C bus?

Related

Using STM32 FMC HAL driver with parallel DAC

Im trying to generate sinusoidal signal with STM32f767 and DAC8412. DAC have 12 bit data bus and 2 bit address to select one of the four analog outputs. I've configuried FMC in CubeIDE for a SRAM memory with 16 bit data and 2 bit addres. I was able to create buffer with 4096 integer values of sin(). Then i've tried to write them to addres 0x60000000, but it only writes 4 values. After that, program goes to HardFault_Handler().
#define SRAM_BANK_ADDR ((uint32_t)0x60000000)
#define RESOLUTION_T ((uint32_t)0x1000)
#define RESOLUTION_Y ((uint32_t)0x1000)
uint32_t aTxBuffer[RESOLUTION_T];
uint32_t address = SRAM_BANK_ADDR;
Thats how i try to send data to DAC:
for (uint32_t i = 0; i<RESOLUTION_T; i++ )
{
*(__IO uint32_t*) address = aTxBuffer[i];
}
Thats how i fill buffer:
static void Fill_Buffer(uint32_t *pBuffer, uint32_t res_T, uint32_t res_Y)
{
uint32_t tmpIndex = 0;
double sinVal;
/* Put in global buffer different values */
for (tmpIndex = 0; tmpIndex < res_T; tmpIndex++ )
{
sinVal = round((sin(M_TWOPI*tmpIndex/res_T)+1)*res_Y/2);
pBuffer[tmpIndex] = sinVal;
}
}

Intel MAX10 I2C doesn't send any signals. how can i fix it?

I use DE10-LITE board.
I try to use I2C for connect with external ROM.
In QSYS, I set up NIOS and I2C Master Core.
there is no error with compile.
it is my code
GPIO(0) <= '0' WHEN SDA_OE = '1' ELSE 'Z';
GPIO(1) <= '0' WHEN SCL_OE = '1' ELSE 'Z';
SDA <= GPIO(0);
SCL <= GPIO(1);
u0 : component QSYS
port map (
clk_clk => MAX10_CLK1_50, -- clk.clk
reset_reset_n => RST, -- reset.reset_n
i2c_0_i2c_serial_sda_in => SDA, -- i2c_0_i2c_serial.sda_in
i2c_0_i2c_serial_scl_in => SCL, -- .scl_in
i2c_0_i2c_serial_sda_oe => SDA_OE, -- .sda_oe
i2c_0_i2c_serial_scl_oe => SCL_OE -- .scl_oe
);
GPIO are inout pins.
and i write program code in Eclips like this.
i2c_dev = alt_avalon_i2c_open("/dev/i2c_0");
if (NULL==i2c_dev)
{
printf("Error: Cannot find /dev/i2c_0\n");
//return 1;
}
while(1)
{
alt_avalon_i2c_master_target_set(i2c_dev,SLAVE_ROM_ADDR);
status=alt_avalon_i2c_enable(i2c_dev);
i2c_tx_buf[0] = 0x00;
i2c_tx_buf[1] = 0x00;
i2c_tx_buf[2] = 0x03;
i2c_tx_buf[3] = 0x04;
status=alt_avalon_i2c_master_tx(i2c_dev, i2c_tx_buf, 4, 0);
}
and i connect gpio pins to oscilloscope. but it doesn't send any signals.
i also use BusBee serial bus monitor for chseck I2C signals. but it can not detect any signals.
what is problem?

Error using serial/fopen (line 72) MATLAB

I am using a pressure sensor D6F-PH to measure the pressure difference. This is my Arduino code that I wrote to get the values from the sensor.
#include "Wire.h"
#define addrs 0x6C // I2C bus address
int P;
int I;
float T;c
int initialize(int i2c_addr)
{
//INITIALIZATION AFTER POWER UP
Wire.beginTransmission(i2c_addr);
Wire.write(0x0B);
Wire.write(0x00);
int x = Wire.endTransmission();
return x;
}
int pressure(int i2c_addr)
{
//MCU MODE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0); // reg 0 - address register high byte
// Wire.write(0x51); // reg 1 - address register low byte
Wire.write(0x40); // reg 1 - address register low byte
Wire.write(0x18); // reg 2 - serial control register - indicate # bytes among others (page 7 bottom)
Wire.write(0x06); // reg 3 - value to be written to SENS control register
int x = Wire.endTransmission();
delay(33);
//WRITE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0);
Wire.write(0x51);
Wire.write(0x2C);
x = Wire.endTransmission();
//READ
Wire.beginTransmission(i2c_addr);
Wire.write(0x07);
x = Wire.endTransmission();
Wire.requestFrom(i2c_addr, 2);
byte hibyte = Wire.read();
byte lobyte = Wire.read();
long raw = word( hibyte, lobyte);
//Serial.print("raw pressure:\t ");
Serial.println(raw);
// D6F-PH5050AD3 ==> rangeMode=500 ==> int rd_pressure = ((raw - 1024) * rangeMode * 2 / 60000L) - rangeMode
// D6F-PH0505AD3 ==> rangeMode=50 ==> int rd_pressure = ((raw - 1024) * rangeMode * 2 / 60000L) - rangeMode
// D6F-PH0025AD1 ==> rangeMode=250 ==> int rd_pressure=(raw - 1024) * rangeMode / 60000L
//int rangeMode = 50;
int rangeMode = 250;
int rd_pressure = (raw - 1024) * rangeMode / 60000L;
//int rd_pressure = ((raw - 1024) * rangeMode * 10/60000L) - rangeMode;
return rd_pressure;
}
float temperature(int i2c_addr)
{
//MCU MODE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0); // reg 0 - address register high byte
// Wire.write(0x51); // reg 1 - address register low byte
Wire.write(0x40); // reg 1 - address register low byte
Wire.write(0x18); // reg 2 - serial control register - indicate # bytes among others (page 7 bottom)
Wire.write(0x06); // reg 3 - value to be written to SENS control register
int x = Wire.endTransmission();
delay(33);
//WRITE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0);
Wire.write(0x61);
Wire.write(0x2C);
x = Wire.endTransmission();
//READ
Wire.beginTransmission(i2c_addr);
Wire.write(0x07);
x = Wire.endTransmission();
Wire.requestFrom(i2c_addr, 2);
byte hibyte = Wire.read();
byte lobyte = Wire.read();
long raw = word( hibyte, lobyte);
//Serial.print("raw temperature:\t ");
//Serial.println(raw);
int temp = round((float)(raw - 10214) / 3.739); // this is the temperature multiplied by 10...
return (temp / 10.0); // ...and the function returs the float
temperature with 0.1°C resolution
}
void setup()
{ // Open serial communications
Wire.begin();
Serial.begin(9600);
I = initialize (addrs); // start wire connection
}
void loop()
{
P = pressure(addrs);
Serial.print("pressure:\t ");
Serial.println(P);
T = temperature(addrs);
Serial.print("temperature:\t ");
Serial.println(T);
delay(300); //delay for 30 seconds
}
I can measure the pressure and the temperature from the arduino uno board using the Serial Monitor.
When I try to Retrieve the data using MATLAB I am unable to do so.
s=serial('COM6','BaudRate',9600);
fopen(s);
This is the error message that I get when I try to open the port : Error using serial/fopen (line 72)
Open failed: Cannot connect to the COM2 port. Possible reasons are another
application is connected to the port or the port does not exist.
I have checked the COM port number and also used the delete(instrfindall); command but to no avail.
Please help
Resolved. I needed to close the Serial Monitor before creating a connection with MATLAB.

How to use Backup SRAM as EEPROM in STM32F4

There are two ways of emulating EEPROM on the STM32F4:
On-chip 4 Kbytes backup SRAM
On-chip Flash, with specific software algorithm
The second option is described here: AN3969.
But google, unfortunately, hasn't been able to provide information on how to use the first option - using the 4Kb of backup SRAM as EEPROM?..
Can anyone help on the topic?
must do these:
Enable the PWR clock
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
Enable access to the backup domain
PWR_BackupAccessCmd(ENABLE);
Enable backup SRAM Clock
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);
Enable the Backup SRAM low power Regulator to retain it's content in VBAT mode
PWR_BackupRegulatorCmd(ENABLE);
and you can write/read datas to sram (these codes from BKP_Domain codes in STM32F4xx_DSP_StdPeriph_Lib) (in my mcu stm32f417 BKPSRAM_BASE=0x40024000)
// Write to Backup SRAM with 32-Bit Data
for (i = 0x0; i < 0x100; i += 4) {
*(__IO uint32_t *) (BKPSRAM_BASE + i) = i;
}
// Check the written Data
for (i = 0x0; i < 0x100; i += 4) {
if ((*(__IO uint32_t *) (BKPSRAM_BASE + i)) != i){
errorindex++;
}
}
then if you want:
// Wait until the Backup SRAM low power Regulator is ready
while(PWR_GetFlagStatus(PWR_FLAG_BRR) == RESET)
{}
you can find these functions in STM32F4xx_DSP_StdPeriph_Lib.
after reading through the Reference Manual for stm32f4 and the stm32f405xx/stm32f407xx datasheet I agree that it isn't clear how to actually use the backup sram (or where it is located). Here is what I found. Both the RTC registers and backup SRAM contain some amount of storage that is maintained as long as you have battery power. The RTC contains 20 registers (80 bytes) and the backup sram (which is its own peripheral on AHB1 and located within the register address region) contains 0x1000 (4096 bytes). Neither are enabled by default.
in DM00037051 (stm32f405xx/stm32f407xx datasheet, p29):
The 4-Kbyte backup SRAM is an EEPROM-like memory area. It can be used to store
data which need to be retained in VBAT and standby mode. This memory area is
disabled by default to minimize power consumption (see Section 2.2.19:
Low-power modes). It can be enabled by software.
The backup registers are 32-bit registers used to store 80 bytes of user
application data when VDD power is not present. Backup registers are not reset
by a system, a power reset, or when the device wakes up from the Standby mode
(see Section 2.2.19: Low-power modes).
on page 71 of datasheet and p65 of the reference manual
AHB1 | 0x4002 4000 - 0x4002 4FFF | BKPSRAM
and page 73 of the datatasheet and p67 of the reference manual
APB1 | 0x4000 2800 - 0x4000 2BFF | RTC & BKP Registers
Page 118-119 of the reference manual contains information on enabling the backup SRAM and RTC registers.
NOTE: if you are already using the RTC in the backup domain and only need to store <= 80 bytes, then you are better off using the RTC backup registers because enabling the backup SRAM will basically double the current consumption (see table 25 in the stm32f405/7 datasheet).
here are my write and read functions for both backup SRAM and backup RTC registers
int8_t write_to_backup_sram( uint8_t *data, uint16_t bytes, uint16_t offset ) {
const uint16_t backup_size = 0x1000;
uint8_t* base_addr = (uint8_t *) BKPSRAM_BASE;
uint16_t i;
if( bytes + offset >= backup_size ) {
/* ERROR : the last byte is outside the backup SRAM region */
return -1;
}
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);
/* disable backup domain write protection */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); // set RCC->APB1ENR.pwren
PWR_BackupAccessCmd(ENABLE); // set PWR->CR.dbp = 1;
/** enable the backup regulator (used to maintain the backup SRAM content in
* standby and Vbat modes). NOTE : this bit is not reset when the device
* wakes up from standby, system reset or power reset. You can check that
* the backup regulator is ready on PWR->CSR.brr, see rm p144 */
PWR_BackupRegulatorCmd(ENABLE); // set PWR->CSR.bre = 1;
for( i = 0; i < bytes; i++ ) {
*(base_addr + offset + i) = *(data + i);
}
PWR_BackupAccessCmd(DISABLE); // reset PWR->CR.dbp = 0;
return 0;
}
int8_t read_from_backup_sram( uint8_t *data, uint16_t bytes, uint16_t offset ) {
const uint16_t backup_size = 0x1000;
uint8_t* base_addr = (uint8_t *) BKPSRAM_BASE;
uint16_t i;
if( bytes + offset >= backup_size ) {
/* ERROR : the last byte is outside the backup SRAM region */
return -1;
}
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);
for( i = 0; i < bytes; i++ ) {
*(data + i) = *(base_addr + offset + i);
}
return 0;
}
int8_t write_to_backup_rtc( uint32_t *data, uint16_t bytes, uint16_t offset ) {
const uint16_t backup_size = 80;
volatile uint32_t* base_addr = &(RTC->BKP0R);
uint16_t i;
if( bytes + offset >= backup_size ) {
/* ERROR : the last byte is outside the backup SRAM region */
return -1;
} else if( offset % 4 || bytes % 4 ) {
/* ERROR: data start or num bytes are not word aligned */
return -2;
} else {
bytes >>= 2; /* divide by 4 because writing words */
}
/* disable backup domain write protection */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); // set RCC->APB1ENR.pwren
PWR_BackupAccessCmd(ENABLE); // set PWR->CR.dbp = 1;
for( i = 0; i < bytes; i++ ) {
*(base_addr + offset + i) = *(data + i);
}
PWR_BackupAccessCmd(DISABLE); // reset PWR->CR.dbp = 0;
// consider also disabling the power peripherial?
return 0;
}
int8_t read_from_backup_rtc( uint32_t *data, uint16_t bytes, uint16_t offset ) {
const uint16_t backup_size = 80;
volatile uint32_t* base_addr = &(RTC->BKP0R);
uint16_t i;
if( bytes + offset >= backup_size ) {
/* ERROR : the last byte is outside the backup SRAM region */
return -1;
} else if( offset % 4 || bytes % 4 ) {
/* ERROR: data start or num bytes are not word aligned */
return -2;
} else {
bytes >>= 2; /* divide by 4 because writing words */
}
/* read should be 32 bit aligned */
for( i = 0; i < bytes; i++ ) {
*(data + i) = *(base_addr + offset + i);
}
return 0;
}
I had to jump from main program to bootloader on user request.
So I put some 'magic number' into BKPSRAM in main program, do CPU soft reset.
Bootloader always starts first.
It checks for 'magic number' if it is present, it executes, else starts main program
when using HAL this is how to jump to bootloader:
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
__BKPSRAM_CLK_ENABLE();
*(__IO uint8_t *)0x40024000 = 42;//magic number
HAL_NVIC_SystemReset();
inside bootloader to read magic number it is enough to enable backup sram clock only (bootloader uses StdPeriphDriver).
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);
extRequest = *(__IO uint8_t *)0x40024000;
if(extRequest == 42)
//run bootloader
cpu is stm32f407
Here is the example of HAL library to use backup SRAM.
#define WRITE_READ_ADDR 0x01 //offset value.you can change according to your application
uint32_t write_arr = 0xA5A5A5A6;
uint32_t read_arr;
int main()
{
enable_backup_sram();
writeBkpSram(write_arr);
while(1)
{
read_arr = readBkpSram();
}
}
void enable_backup_sram(void)
{
/*DBP : Enable access to Backup domain */
HAL_PWR_EnableBkUpAccess();
/*PWREN : Enable backup domain access */
__HAL_RCC_PWR_CLK_ENABLE();
/*BRE : Enable backup regulator
BRR : Wait for backup regulator to stabilize */
HAL_PWREx_EnableBkUpReg();
/*DBP : Disable access to Backup domain */
HAL_PWR_DisableBkUpAccess();
}
void writeBkpSram(uint32_t l_data)
{
/* Enable clock to BKPSRAM */
__HAL_RCC_BKPSRAM_CLK_ENABLE();
/* Pointer write on specific location of backup SRAM */
(uint32_t *) (BKPSRAM_BASE + WRITE_READ_ADDR) = l_data;
/* Disable clock to BKPSRAM */
__HAL_RCC_BKPSRAM_CLK_DISABLE();
}
uint32_t readBkpSram(void)
{
uint32_t i_retval;
/* Enable clock to BKPSRAM */
__HAL_RCC_BKPSRAM_CLK_ENABLE();
/* Pointer write from specific location of backup SRAM */
i_retval = *(uint32_t*) (BKPSRAM_BASE + WRITE_READ_ADDR);
/* Disable clock to BKPSRAM */
__HAL_RCC_BKPSRAM_CLK_DISABLE();
return i_retval;
}
I'm currently using the an STM32F2xx microcontroller. According to the datasheet:
The 4-Kbyte backup SRAM is an EEPROM-like area.
To retain the content of the RTC backup registers … when VDD is turned off, VBAT pin can be connected to an optional standby voltage supplied by a battery or by another source.
A supercap, for example, would be required to maintain the contents of the backup registers while the microcontroller is powered off.
Also, according to the document:
After reset, the backup domain (… backup SRAM) is protected against possible unwanted write accesses. To enable access to the backup domain, proceed as follows …
It gives you instructions on how to gain access to the backup domain by directly writing to the certain peripheral register. If you have access to the STM32F4xx library, you can call something like this (note: I'm using the STM32F2xx library):
PWR_BackupAccessCmd(ENABLE);
Note: There's is more to it than simply calling the above function, such as enabling the backup SRAM interface clock. Consult the STM32F4 series documentation.
There is a lot of documentation embedded in the library source that is invaluable and if it's available should be read.
On the STM32F2 series microcontroller, SRAM is located at the following memory address range:
0x40024000 - 0x40024FFF
And can be written to somewhere at location, for example, as follows:
#define VAR_LOC ((volatile uint8_t *)(0x40024000))
volatile uint8_t *pVar = VAR_LOC;
*pVar = 5;
Useable example
In header:
//------------------------------------
typedef struct
{
uint32_t isDefault; //must by 0x12345678
uint32_t LastTestNumber;
uint32_t LastUserNumber;
uint32_t LastModeTest;
uint32_t calibv;
uint32_t calibc;
uint32_t WorkTime;
int32_t RTCCalib;
uint32_t LCDContrast;
} sBKPSRAM;
extern sBKPSRAM *BKPSRAM;// = (sSDRAM *)SDRAM_BANK_ADDR;
//------------------------------------
In code head
define as data:
sBKPSRAM *BKPSRAM = (sBKPSRAM *)BKPSRAM_BASE;
In Init:
void main(void)
{
(....)
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);
PWR_BackupAccessCmd(ENABLE);
PWR_BackupRegulatorCmd(ENABLE);
ifDefault();
(....)
}
In procedure:
//-------------------------------------------------
void ifDefault(void)
{
if (BKPSRAM->LastModeTest!=0x12345678)
{
printf("BKPSRAM to default\r\n");
memset(BKPSRAM,0,sizeof(sBKPSRAM));
BKPSRAM->calibv =66920;
BKPSRAM->calibc =79230;
BKPSRAM->RTCCalib =1;
BKPSRAM->LCDContrast =2;
BKPSRAM->LastModeTest =0x12345678;
}
}
//-------------------------------------------------
HAL Configuration for STM32H7 to access backup SRAM:
#define BKP_RAM (*(__IO uint32_t *) (D3_BKPSRAM_BASE)) //Start address: 0x38800000
Main() {
__HAL_RCC_BKPRAM_CLK_ENABLE();
HAL_PWREx_EnableBkUpReg();
BKP_RAM = 0xA5AA5A55;
}
In addition to that, you need to add a below line in systemInit() to enable write-through access to Backup SRAM.
SCB->CACR |= 1<<2;

Msp430 i²c module and libraries

I have a project that has a MSP430G2553 master device and a Triple-Axis Digital-Output Gyro ITG-3200 Breakout slave. ITG3200 uses i²c protocol to communicate so i've been checking out the i²c module usage on Msp. For a starter i downloaded the TI I²c examples which can be found in http://www.ti.com/lsds/ti/microcontroller/16-bit_msp430/msp430_software_landing.page After i debugged the first code which is between a MSP master and a TMP100 temperature sensor as a slave. Here is the sample code.
//******************************************************************************
// MSP430G2xx3 Demo - USCI_B0 I2C Master to TMP100, Set P1.0 if Temp > 28C
//
// Description: I2C interface to TMP100 temperature sensor in 9-bit mode.
// Timer_A CCR0 interrupt is used to wake up and read the two bytes of
// the TMP100 temperature register every 62ms. If the temperature is greater
// than 28C, P1.0 is set, else reset. CPU is operated in LPM0. I2C speed
// is ~100kHz.
// ACLK = n/a, MCLK = SMCLK = TACLK = BRCLK = default DCO = ~1.2MHz
//
// /|\ /|\ /|\
// | TMP100 10k 10k MSP430G2xx3
// | ------- | | -------------------
// +--|Vcc SDA|<-|---+->|P1.7/UCB0SDA XIN|-
// | | | | | |
// +--|A1,A0 | | | XOUT|-
// | | | | |
// +--|Vss SCL|<-+------|P1.6/UCB0SCL P1.0|---> LED
// \|/ ------- | |
//
// D. Dang
// Texas Instruments Inc.
// February 2011
// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include <msp430.h>
unsigned int RxByteCtr;
unsigned int RxWord;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= BIT0; // P1.0 output
P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0
P1SEL2|= BIT6 + BIT7; // Assign I2C pins to USCI_B0
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 12; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
UCB0I2CSA = 0x4e; // Set slave address
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
IE2 |= UCB0RXIE; // Enable RX interrupt
TACTL = TASSEL_2 + MC_2; // SMCLK, contmode
while (1)
{
RxByteCtr = 2; // Load RX byte counter
UCB0CTL1 |= UCTXSTT; // I2C start condition
__bis_SR_register(CPUOFF + GIE); // Enter LPM0, enable interrupts
// Remain in LPM0 until all data
// is RX'd
if (RxWord < 0x1d00) // >28C?
P1OUT &= ~0x01; // No, P1.0 = 0
else
P1OUT |= 0x01; // Yes, P1.0 = 1
__disable_interrupt();
TACCTL0 |= CCIE; // TACCR0 interrupt enabled
__bis_SR_register(CPUOFF + GIE); // Enter LPM0, enable interrupts
// Remain in LPM0 until TACCR0
// interrupt occurs
TACCTL0 &= ~CCIE; // TACCR0 interrupt disabled
}
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void TA0_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF); // Exit LPM0
}
// The USCIAB0TX_ISR is structured such that it can be used to receive any
// 2+ number of bytes by pre-loading RxByteCtr with the byte count.
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
{
RxByteCtr--; // Decrement RX byte counter
if (RxByteCtr)
{
RxWord = (unsigned int)UCB0RXBUF << 8; // Get received byte
if (RxByteCtr == 1) // Only one byte left?
UCB0CTL1 |= UCTXSTP; // Generate I2C stop condition
}
else
{
RxWord |= UCB0RXBUF; // Get final received byte,
// Combine MSB and LSB
__bic_SR_register_on_exit(CPUOFF); // Exit LPM0
}
}
I built up the same circuit where 2 10k pull ups on SDA and SCL, changed the slave address to either 0x69 or 0x68 which is the gyro address given in the user guide of the device. Since i did not built up any monitoring yet, i used an oscilloscope to check out the pulses on SCL and SDA. I didn't expect to see anything on SDA yet but what i am wondering is why i can't even see any clock cycle on SCL bus. It is either always on 3.3V (MSP internal vcc) or sometimes, its near 1V (0.80~). Even when i remove the gyroscope, SDA and SCL bus, i can't see any pulses on P1.6 port. Any ideas?