I have implemented i2c master code for reading temperature value from temp sensor(slave).i am testing my code on FPGA evolution board.FPGA is Microsemi nano very basic FPGA.How can I test my master without connecting to the slave device?
I recommend writing a test bench that simulates the behavior of a slave device and checks for the correct sequence of actions from your I2C master and use it in simulation.
Related
I have one beaglebone black which has am335x processor and uses linux kernel 5.4. I want to just send and receive data on Tx Rx at uart4 using serdev driver(not use /dev/tty layer). so I find one example code which is drivers/iio/chemical/pms7003.c But this example based on slave sensors and it is not work in my case. so anyone helps me how to use uart using serdev driver to Write and read data on the Tx Rx line without a slave device?
Hi I am new to kernel driver developement. I am using the raspberry pi as my hostI am trying to create an I2C driver for a custom board we have. The custom board will act as the slave. I am confused about how do I go about entering the devices slave address. From what I understand
You need to either have a board setup file which I dont since its a custom board.
You can edit the device tree
Or you can do it in the user space application.
I am not sure where exactly to edit the device tree if I go with the second option. More over I would like to somehow register the slave address in the I2C driver itself. That way I donot need to rebuild the kernel. One method i was looking at was to set the i2c client from the driver code but that was advised by commentators I am not sure why. Any help would be appreciated.
Instantiating Drivers
So I have finally a working way in which I can bind the I2C device without needing a kernel rebuild. I create two driver files(.ko files). One for registering and one for the actual driver.
The way I did it is I got the bus number to which the device was connected.
(You can look into i2c user space code. i2cdetect -y (busnumber) will help you detect which bus number it is)
Once I knew that I created a driver file which would register my device by getting access to the adapter and then registering it. My bus number was 1 and slave address 0x10
static struct i2c_board_info board_info[] __initdata =
{
{
I2C_BOARD_INFO("my_device", 0x10),
},
};
And in the init function of the driver I register the device by
i2c_new_device(i2c_get_adapter(1), board_info[0])
Thats it. Now once you build this insmod the ko file before insmoding the actual driver file and everything should work.
Im using MCP25625 which is MCP2515+integrated MCP2551 and trying to send messages in a loop.
For some reson I dont see any signal at all on CANH, CANL lines.
SPI communication works correctly
I use software reset procedure
There is clear 20Mhz sinewave from Crystal
There is TXCAN signal
At the moment there is nothing at all connected to CANL,CANH, just the probe.
I also tried to run in LOOPBACK mode and it works, but in the NORMAL modethere is nothing coming out.
Seems like transciever is broken? I changed 2 chips already, so it shouldnt be the problem.
Any suggestion guys?
Schematics
have you considered the modes of operation of the CAN transceiver?
In your schematic, the pins value is not clear.
If you have connected it to the MCU, Please pull it to LOW to select the normal operation mode for the transceiver (it is different configuration then the CAN controller settings, hence might cause some confusion!).
Controlling it by MCU is a good choice as it gives more control to prevent network communication from being blocked, due to a CAN controller which is out of control.
Else, connect it to ground to ensure normal operation mode specifically for the build in transceiver.
I have referred the data-sheet's of MCP25625, MCP2515 and TJA1050 to bring out this conclusion.
TJA1050 has pin-S for selecting high-speed mode and silent mode. Both modes are similar to normal mode and standby mode respectively of the transceiver of MCP25625.
Also, pin-S configuration in TJA1050 is similar to pin-STBY configuration in MCP25625.
0(LOW) for high-speed/normal mode of TJA1050/MCP25625-Transceiver
1(HIGH) for silent/standby mode of TJA1050/MCP25625-Transceiver
Hope this helps.
At the moment there is nothing at all connected to CANL,CANH, just the probe.
Hope you have connected the termination resistor? It is on the schematic, but ...
I am working on some project where I need to communicate between two processors (hardware), ATxMEGA128A1 AVR Controller and Blackfin BF522 Digital Signal Processor. Someone help me.
Here, to communicate between a DSP and a UController you can use asynchronous serial link USART that's called as Inter-Processor Communication(IPC).
You can code for GPIO pins if you know how to write code for USART,that's available on almost any UController.
In-short you need USART channel to communicate between DSP and UController(IPC).That's the one possible way I don't know about others.
I am currenlty trying to monitor my battery status through SMBus.
I have a battery along with a control board that constantly outputs the battery status.
This control board is then connected to my mother board through a I2C-USB module.
I need to write a program to recognize the SMBus connection and transmit the battery status to the user.
I'm a beginner when it comes to dealing with smart batteries and I2C/SMBus, and I'm somewhat lost with how to approach this problem.
Any help of suggestions would be appreciated. Thanks.
Your question is a bit lacking. What kind of I2C-USB module? Or rather does it come with a Linux driver? If it does you probably won't need to write one. An application will do. You can read more about I2C and SMBus here.
Basically what you need is the I2C address of the control board (a single byte). When you have the address you (as the master) issue read commands over the I2C bus to the control board using its address and reads the response. If there's a driver for the I2C-USB module this should be straightforward enough. Plug in the device and open() the device (/dev/[i2c-usb-name] where [i2c-usb-name] is the name of the device). Then follow the driver implementer's guide how to setup and send data over that device (typically using read()/write() or ioctl()). Here are some additional information on working with I2C from user space: http://www.mjmwired.net/kernel/Documentation/i2c (select topics in the menu on the left hand side).
If you must write the driver yourself, the first stop for a Linux device driver beginner is the LDD3. Read it, it's quite a pleasant read.