I am trying to introduce an I2C communication in an NXP SDK program which I can edit in MCUXpresso. I have searched for different functions and found this one. The issue is that I know how to define the first to parameters, but I´m unable to figure out how to use or define the last parameter void *callbackParam.
HAL_I2cSlaveTransferInstallCallback(hal_i2c_slave_handle_t handle, hal_i2c_slave_transfer_callback_t callback, void *callbackParam)
I´m also struggling to create an I2C task, I assume this function is the one I was looking for, but I´m not sure.
Related
I am trying out this MCU / SoC emulator, Renode.
I loaded their existing model template under platforms/cpus/stm32l072.repl, which just includes the repl file for stm32l071 and adds one little thing.
When I then load & run a program binary built with STM32CubeIDE and ST's LL library, and the code hits the initial function of SystemClock_Config(), where the Flash:ACR register is being probed in a loop, to observe an expected change in value, it gets stuck there, as the Renode Monitor window is outputting:
[WARNING] sysbus: Read from an unimplemented register Flash:ACR (0x40022000), returning a value from SVD: 0x0
This seems to be expected, not all existing templates model nearly everything out of the box. I also found that the stm32L071 model is missing some of the USARTs and NVIC channels. I saw how, probably, the latter might be added, but there seems to be not a single among the default models defining that Flash:ACR register that I could use as example.
How would one add such a missing register for this particular MCU model?
Note1: For this test, I'm using a STM32 firmware binary which works as intended on actual hardware, e.g. a devboard for this MCU.
Note2:
The stated advantage of Renode over QEMU, which does apparently not emulate peripherals, is also allowing to stick together a more complex system, out of mocked external e.g. I2C and other devices (apparently C# modules, not yet looked into it).
They say "use the same binary as on the real system".
Which is my reason for trying this out - sounds like a lot of potential for implementing systems where the hardware is not yet fully available, and also automatted testing.
So the obvious thing, commenting out a lot of parts in init code, to only test some hardware-independent code while sidestepping such issues, would defeat the purpose here.
If you want to just provide the ACR register for the flash to pass your init, use a tag.
You can either provide it via REPL (recommended, like here https://github.com/renode/renode/blob/master/platforms/cpus/stm32l071.repl#L175) or via RESC.
Assuming that your software would like to read value 0xDEADBEEF. In the repl you'd use:
sysbus:
init:
Tag <0x40022000, 0x40022003> "ACR" 0xDEADBEEF
In the resc or in the Monitor it would be just:
sysbus Tag <0x40022000, 0x40022003> "ACR" 0xDEADBEEF
If you want more complex logic, you can use a Python peripheral, as described in the docs (https://renode.readthedocs.io/en/latest/basic/using-python.html#python-peripherals-in-a-platform-description):
flash: Python.PythonPeripheral # sysbus 0x40022000
size: 0x1000
initable: false
filename: "script_with_complex_python_logic.py"
```
If you really need advanced implementation, then you need to create a complete C# model.
As you correctly mentioned, we do not want you to modify your binary. But we're ok with mocking some parts we're not interested in for a particular use case if the software passes with these mocks.
Disclaimer: I'm one of the Renode developers.
I need to turn a complex simulink model that runs in realtime, receive & send data using sharedmemory and socket every 100ms, contains exernal C++ callback functions(for sharedmemory and socket), into an executable. There is no need for UI like graphs or buttons(maybe print some log but nothing more).
I'm quite new to simulink, what is the easiest way to compile such a simulink model into an executable? Would be great if there is also a super detailed guide.
Also a side question - is using C function block(and converting structs to buses) the preferred way to use sharedmemory and socket in simulink? Any better substitution?
Any help would be appreciated. Thanks in advance!
I have a Modbus server implemented with pymodbus. This server has a thread that update the internal registers to simulate a variable environment from the field. I need to update a file when I receive a frame containing a write function code. I tried to implement the CustomDataBlock as suggested here, but that's not exactly what I need: in this example, the code is called every time a value is changed, hence also in my "internal" updating writer function.
I want some code to be called only when my server receive a frame with writing function codes.
Any idea?
Thank you
I found the solution by myself:
inherit ModbusRtuFramer
overload processIncomingPacket function
I have just started to work with PLCs and I need to modify parameters of a sinamics from a PLC. I know that they may have different accesible levels and that they are modified by functions. So the question is:
Can I the parameters be directly modified?
Or if it is not possible, how do I programm and include that functions?
At least try to find some information.
http://support.automation.siemens.com/WW/view/en/34677186/136000&cspltfrm=39&cssw=0&csbinh=8
Sinamics drives parameters can be modified from the plc code using _writedriveparameter function.
One thing to remember is: never use this function in two places at the same time. If you do it the function hangs and to restore the correct working it is necessary to reboot the cpu.
Also remember to check the function result to call the function in the correct way (result 7001,7002,7003 ecc). You have to check if the function is already working or not.
I am trying to send/retreieve data from/to FPGA using Matlab. I connected FPGA using Virtual com port. Now how to send data from Matlab to FPGA or read data of FPGA ?
FTDI 2232H is on the FPGA as well. I connected external LED's and switches on the I/O ports of the FPGA.
I am new in this field, so want some guideline to start communication b/w MAtlab and FPGA:
I tried following code:
s1= serial('COM9')
fopen(s1)
. Is it the right way to communicate ? Kindly guide. thanks
FPGA's are configured using a Hardware Description Language (HDL) such as Verilog or VHDL. These languages let you specify how the switch configuration within the FPGA, which in turn lets you construct your custom digital logic and processing system.
The HDL Coder Toolbox in Matlab lets you design and prototype your custom logic using higher-level functions, which are then translated into HDL and can be be used to directly program your chip. This tutorial describes the process in detail.
If you already have a design implemented on your FPGA and want to communicate with that implementation, you would use Matlab's serial port communication functions. The exact protocol will depend on the interface you have implemented.
Some intermediate debugging steps I find helpful:
Verify that you can send serial port data from your computer. In Windows XP, you can do this easily with HyperTerminal, and hooking up a scope to the output pins of your serial cable. Set up a trigger to capture the event. For Windows 7 and newer, you'll need to download a HyperTerminal client.
Repeat this same process with Matlab. Using a scope, verify that you see the serial port signal when sent from Matlab, and that the output matches the results from step 1. Again, set up a scope trigger to capture the event.
Now connect the serial cable directly to the FPGA board. Modify your HDL to include a latch on the serial input that displays the output on the LED's. Verify that your board initializes to the correct LED state, and that the LED state changes when you send the serial message.
Lastly, verify that you are interpreting the message correctly on the FPGA side. This includes making sure that the bit-ordering is correct, etc. Again, the LED outputs can be very helpful for this part.
The key here is to take small, incremental steps, physically verifying that things are working each step of the way.