SH72867 with I2C - i2c

I am using ‘SH72867(Renesas)’ connect with ‘EEPROM(24LC04B)’ . In the customer’s document at ‘address 0xF0 of EEPROM have data 0x5555’, But when I reading from this address always return ‘0xFFFF’ and same with other address.
I can’t write to EEPROM too.
I used I2C sample of Renesas but not run.
Do you have any suggestion about setting up I2C?
Sorry for my bad English and no clear explanation.
Any help apprciated,
Thanks

Verify the common issues:
Data and clock are connected properly.
Pull up resistor on clock and data connected to VCC.
Loop the I2C read request, connect scope and verify that I2C signals are OK. In addition check the ACK bit.
Verify clock is lower then 400kHz.
When using code examples, they usually fit to specific board. Verify that the code example configuration is the same as your board.
Some MCU may have more then one I2C pinout options. The code example might use I2C module that connected to diffrent pins.

Related

stm32f407 ADC cannot read data

i need some help.
i built custom board and had problem with my adc reading, it's not software problem...yet.
my question is really hardware. it might be my lack of understanding from reading STM32f407 manual book. so i have my microcontroller STM32f407zgt6 with LQFP144 package. and i fail to read the ADC. i use stm32cubeide for programming but my programming is very simple since i follow this link https://deepbluembedded.com/stm32-light-sensor-ldr-interfacing-ambient-light-sensor-project/. my question is:
do i have to connect pin VREF+ to VDDA externally to activate the ADC?
cause in STM32f103 with LQFP48. the VREF+ pin doesn't exist and the manual says that it's internally connected to VDDA pin. can i assume that the same rules can be applied to STM32f407ZGT6? or the external connection of VREF+ -> VDDA is mandatory since it is using LQFP144 package? cause i didn't connect it in my custom board and left the VREF+ pin hanging.
i just wanna use the ADC VREF+ = VDDA in LQFP144, so i assume that it is internally connected, is my assumption wrong?
here is my confusion on STM32F4 manual:
and
please help. i might have a false design on my custom board then...
In the smaller packages Vref is connected internaly just to save external pins.
In the larger packages Vref can be connected to a different power rail - more stable or slightly different, like 3.0V. And there is no configuration options to connect Vref to Vdda. The datasheed states explicitly in the "General operation conditions" chapter:
And in most cases, Vref is just wired to Vdda.

Connecting two PC's via RS485 (USB to RS485 converter)

I'm trying to establish Modbus RTU connection (for learning purposes) between two PC's (Win10). I'm using two USB to RS485 converters (D- connected together and D+ also connected together). This converters are connected to USB2.0 ports.
USB to RS485 converter
So I'm using "Modbus Poll" and "Modbus Slave" from "modbus tools".
First computer act as slave and has the following settings:
Slave configuration
Slave definition
Second computer act as master and has following settings:
Master configuration
Master definition
And my problem is, everytime i get "Timeout error":
Timeout error
So, what I'm doing wrong? I'm pretty sure converters are not damaged, because Win10 detecs them.
After all I just want to send simple value to another computer (via Modbus RTU) :)
Thanks
Well, this is not a real answer but I can provide some debugging suggestions.
In the past, I had problems with that RS-485 hardware you're using. It didn't work and I'm not sure why. The one I have uses a strange logic to drive DE pin of the MAX485. If I remember correctly, it inverts the TX line coming from CH340G using a NAND gate and feeds it to DE pin. I'm not sure if it was the problem, but I don't think it's a good design.
You may need pull-up and pull-down resistors on RS-485 lines to prevent it from floating when no driver is driving the bus. Some converters include them internally. Also, you may need 120 ohm termination resistors on both ends.
Instead of working with RS-485, you can simply use TTL logic for testing purposes. Use two USB-TTL converters, connect TX to RX (cross connection).
When debugging communication buses (USART, SPI, I2C etc.) always use logic analyzers. Even the cheapest one saves hours of debugging time.
you need to install proper drivers. I used following link which includes a how to video as well as download link for the drivers . Also disable RTS as its 2 wire RS485 so RTS cant be used.

Is there a CAN bus library for STM32 to direct connect with a CAN transceiver?

Many STM32 chipsets support 1 or 2 channel CAN PIN Outs.
Is there a CAN bus library for STM32 to direct connect with a CAN transceiver such as MCP2551? But it does not matter what the CAN transceiver is.
A CAN transceiver is just a high speed step down converter. (on a basic level)
CAN protocol works in a variant of voltage ranges. MCP2551 is a set CAN transceiver suitable for 12V and 24V systems. With added features to help with the physical layer like externally-controlled slope for reduced RFI emissions, detection of ground fault, voltage brown-out protection, etc.
It has no dependency on the CAN logic. It is just to help you with the bare physical layer.
To answer your question:
As RishabhHardas recommended, use the HAL library provided by STM32 through CubeMx.
Using CubeMx
This is a software provided by ST-Micro to help you setup the boilerplate code for any peripheral application.
You can also check out the examples projects provided by STM in the Cube. This will give you a kick-start in understanding CAN on STM32
STM32Cube_FW_F4_V1.9.0\Projects\STM324xG_EVAL\Examples\CAN\CAN_Networking
After setting it up, you'll be able to call HAL_CAN_Transmit() and HAL_CAN_Receive() by including the header.
Check out this discussion on STM32-Community.
For software, look for the CANtact open source project on Github. It is an implementation for the STM32F042. I had to adapt the project to build it under Atollic but it was not too hard and it works. It provides a SLCAN type of interface over a virtual COM port over USB, which is very fast and convenient.
There is also CAN code for the STM32F103 (Bluepill) (Google "lawicel-slcan") but that chip is not as convenient because you cannot use both CAN and USB at the same time (they share RAM buffers) so if you want CAN, you will not have USB, and routing the CAN messages over a UART will severely limit the bandwidth. That may be OK if your entire application runs on the STM32.

i2c address conflict between MPU6050 and DS3231

I am using MPU6050 onboard a GY-86 module. I also have a DS3231 RTC module. when i searched each data sheet i found that DS3231 and MPU6050 have same i2c address which is 0x68. I have read in the MPU data sheet that if i connect the AD0 pin to 3.3 the the address becomes 0x69. but i can't find any AD0 on my module . i only have vcc-3.3v-SCL-SDA-INTa-FSYNC-DROY
I think i have to change i2c address of mpu6050 or ds3231. so that they won't conflict . how can i change i2c dress of MPU or DS module.
Looking at the GY-86 schematic I found, the AD0 pin is hard grounded on the board. This means that unless you can find a trace on the board to cut (unlikely), there is no way to change the MPU6050 slave address. As far as I can see, the DS2321 cannot change its address either.
This leaves you with a few choices:
Change out on of the devices to a different model with a different address. I expect you really don't want to do this.
If your master device (which you did not specify) has multiple I2C bus controllers, hook each device to a different bus.
Use an I2C multiplexer to put the devices on different "virtual" busses. Here's a module with a 1-8 multiplexer which should do the job (though only a 1-2 is really necessary).

Power save mode STM32F205RG

I am using STM32F205RGT6 Cortex-M3 microcontroller and coding with IAR Embedded Workbench.
I plan to keep the microcontroller in a power saving mode most of the time except when an external component tries to either communicate via SPI (the STM32 microcontroller is meant to be a SP slave) or via USB.
One external compinent is connected via SPI (PB12-15) and PC is connected via USB (PA11-12).
The communication works fine - I have tested both the SPI as well as USB.
I figured that once I am done setting up SPI and USB I will call a power saving function and add the same function call at the end of interrupt service routines. I have found PWR_EnterSTANDBYMode and PWR_EnterSTOPMode (in stm32f2xx_pwr.h) both of which I tried using.
However with such arrangement I cannot establish any communication (SPI or USB) with the microcontroller.
Is there something extra that needs to be configured (for example which pins should wake the microcontroller up)?
Am I using wrong function? Or wrong header file?
Can you point me to an example resembling such case (I could not find anything similar on ST's website)?
Any constructive feedback would be welcome.
In the mean time I found the application note AN3430 (http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/APPLICATION_NOTE/DM00033348.pdf) which is somehow more digestible (only 38 pages) which gives an excellent overview on power saving in the microcontroller.
Since I don't have access to PA0-WKUP (the wake-up pin) I had to discard using stand-by. Seems that just a simple sleep mode in main loop - by calling __WMI(); - should lower current consumption enough in my case. I might consider stop mode if sleep mode isn't enough but I will have read fragments of datasheet on configuration of EXTI registers that the application notepoints to.