Combining Lime Suite with C API

Hi there,
I am modifying Lime Suite for a custom board to run with C API([]) . My main aim is to communicate directly to LMS7002M chip via SPI protocol from Raspberry pi without any USB device like FTDI.

I thougth it was easy , I just had to modify Modify_SPI_Reg_bits with LMS7002M_spi_write and it would work . However, there is too much initialization in lime suite like LMS_Open initializes lms_device_t device* which is cast into lime::LMS7_Device lms* . This new object is used to call functions like

As I have no USB connection , these objects would never get initialized and I always get an error “Device cannot be NULL.” . How do I create dummy versions of these objects , so I can call all functions successfully ?
Is there a step by step procedure which I can follow ?

Tagging @IgnasJ.

To integrate your board into LimeSuite GUI/API, at first you need to create new or modify existing connection. There is already one SPI connection for RPi that was created for LimeNet-Micro, so it may give some hints .

Implementing device enumeration, open/close, and LMS SPI read/write functionality in connection will probably be enough to change LMS chip settings from LimeSuiteGUI. However, there will be errors when LimeSuite attempts to configure FPGA (or other on-board stuff ). To deal with board specifics, you will need to create new or modify existing device class (lime::LMS7_Device or derived).

1 Like

@IgnasJ In the LimeNet-Micro is the raspberry pi connected via the FPGA or directly via SPI lines ?

LMS7002m, ADF4002, DAC and FPGA are connected to RPi SPI1. SPI1 is used for configuration (what is being controlled is selected by chip selects).
SPI0 is used for sample data transfer and is connected to FPGA, which takes samples from LMS via LML interface.

This is assuming ConnectionSPI is used. If ConnectionFTDI is being used (different FPGA gateware), then everything goes through FPGA and USB (FTDI chip).

1 Like

@IgnasJ , I am running the example dualRXTX with the changes suggested . I created a new device for my Raspberry Pi . I am getting an error
TuneVCO(CGEN) - failed to lock (cmphl!=0) SetFrequencyCGEN(80 MHz) failed

CGEN lock failure can be caused by incorrectly set reference clock. Do you set LMS reference clock anywhere? You can set reference clock by using LMS_SetClockFreq(device, LMS_CLOCK_REF, freq) after opening device or you can set it in your device class (e.g.

@IgnasJ . Ok I will try that . By the way, how can I see the debug messages by lime::debug ?

default log handler prints debug messages only in debug configuration:

so either compile debug, register another log handler (LMS_RegisterLogHandler) or modify default log hanlder (if you are modifying LimeSuite anyway).

1 Like

I enabled NDEBUG . Now it says ,
SetFrequencySXT(1200 MHz) - cannot deliver frequency . Its drawing about 200mA of current so I know the program is enabling channels at least but it cannot set set the SXT Frequency to 1.2 GHz .

If SXR and CGEN now locks then it is not reference clock issue. It may be related to power delivery. Can you use LimeSuiteGUI? You could try enabling internal LDOs from GUI.

If you cannot use GUI, you should be able to enable all internal LMS LDOs by adding:

LMS_WriteLMSReg(device, 0x92, 0xFFFF);
LMS_WriteLMSReg(device, 0x93, 0x03FF);
LMS_WriteLMSReg(device, 0xA6, 0x0001);

after LMS_Init() .

1 Like

Thank you @IgnasJ . That was the issue .

As I understand you are using external LDOs for LMS7 chip (as other things work without enabling internal LDOs). That means that is something wrong with your external LDOs that should supply SXT module. Also, you probably do not need to enable all internal LDOs to fix this (only those that are required for SXT).