Main Site Documentation

Simple example of RLPLite with Cerberus?


Could anyone point me to a source/simple expample using RLPLite to toggle a digital pin - where you from C# specify pin and state (true/false) - and maybe a 3th param where you set a delay in ms where it toggles the pin back to original state.

Just to get me started in the C/RLPLite world




I don’t remember there is a such example, but it shouldn’t be hard to do.

Take a look at the MCU datasheet. All you need to do is set few bits in a couple of registers.


Here is a simple example of how to modify the register values in the Cerb:

You will have to find the STM32F405 spec sheets to lookup which register addresses to modify.


Sound easy enough when you have the know-how :wink: Thats why I want the simplest example so I have somthing to poke into.

A simple C method that takes 2 arguments from C#, where the first could be 2 pin numbers, and the second argument could be the on/off state of those pins…

Edit: and the sister method in C# to call into the C method.


That example poke the register from C#. I’m already doing that, but its way too slow.


try GHI.Premium.Native>RLP class

you want RLPext


Whoops that’s premium and you have OSHW :frowning:


@ danibjor

This is an example on how to use RLPLite on the Cerberus and OSHW. While it does not show how to access the registers, it does show you how to use the basics of RLPLite.

To access the registers, you would use C code the same to access the memory directly like you would in any other C program.

As with the Registers example you mentioned, those functions basically typecast the address you use as an unsigned int(32bit) pointer. Typecast an address as an unsigned int pointer and access the register the same way in your RLPLite program.


My bad - I didnt play with the registers. Im calling C# abstraction libraries to do what i want.

I think I’m way deep on this one. I have no experiense with microcontrollers before I bought my first stuff from GHI a few weeks ago. Reading datasheets of a few hundred pages is way over my head.

What i could find (if i read understand it correct) from the technical reference manual, the GPIOA-I registers live omn the AHB1 bus, in the registers

0x40020000 - 0x400203FF - GPIOA

0x40022000 - 0x400223FF - GPIOI

But the stuff in between having an array of port numbers with 0/1 state, to getting v+ out on the pin is beyond me…


@ danibjor

Which C# abstraction libraries are you calling? Can you provide an example of what you are doing?


@ Aron - I had a library witch works much the same way as talking to a module driver… but i have to do the work in C# code.

I’m striving to simulate PWM on 8 pins, multiplexing those signals down to 3 ICs to get a total of 24 PWM outputs.

The C# code is way to slow for this stuff, so my attempt is RLP to gain speed so i can PWM 8 IOs from 2 main board sockets, with 3 IOs for chip select and 1 for output enable. Ideally this would allow me to set the “brightness” of 24 LEDs with a value of 0-255.

If I at first can figure out how to just turn on/off 1 pin on one socket, the rest should be a walk in the park (compared to the learning curve on the first part).


What mainboard are you using? The Premium Libraries has a library function called signal generator which may provide you with the 24 “PWM” that you need:


@ danibjor - Let’s work your way up to the goal.
[ol]download: . Although, the entire example set is for Premium RLP it will be usefull.
Take a look at the addresses/sizes for Cerb:
reference forum thread (it looks to me like the code there didn’t work because of a typo in the c# side with the address (0x20000001 should have been 0x20000000)
per Aron’s suggestion take the above ingredients and follow the recipe in the RLPLite documentation.
Goal here is to get a working RLPLite procedure that uses test RLP_test1.c from the file going as RLPLite, all you want to do is get familiar with the procedure and handling arguments. Then step 2 will be register access.


I found out how to load the dll, set the pointer to my C method in C#. Call the method that just returned an int (for testing) and check the returned value and it look ok.

I’ll look at the zip and see what we got there.

Thanks for taking the time. Really appreciate it!


Looked at the sample code and here is where I stand.

Calling into the C method (RLP) is working well, i know i hit the right method as i get a hardcoded return value of 42 back from it.

I’m now trying to write to a single (hardcoded) pin from C, using

RLPext->GPIO.EnableOutputMode(41, 1);
RLPext->GPIO.WritePin(41, i % 2 == 0);

I got the value 41 from GetSocket(7,).CpuPins[5].

I’m printing out debug info the the Char display - and right after it called the C extention where I enable/write to the pin, the Cerb reboots (you can hear the windows usb unplug/plug back in-sound). Just returning a value 42 works fine tough.

Another thing is, with RLPLite you only have one Invoke method (with a few overloads).

            public int Invoke(float[] VoidArray, int[] IntArray, byte[] ByteArray);
            public int Invoke(int[] VoidArray, int[] IntArray, byte[] ByteArray);
            public int Invoke(sbyte[] VoidArray, int[] IntArray, byte[] ByteArray);
            public int Invoke(uint[] VoidArray, int[] IntArray, byte[] ByteArray);

I don’t see how these maps over to C-style methods… and what the those

int StartLEDBlink(unsigned int *generalArray, void **args, unsigned int argsCount, unsigned int *argSize)

and even worse when you throw in stuff like void** foo[], and then again the examples cast that to char/byte arrays ???

I tried sending in very simple stuff from C# to C++, like

 { 43 });

when I try to grab the first object from the different params in the C method, i get nothing like those values back. Got somhting like 62 and 255 from the different params (If i recall correct).


@ danibjor - Are you still on Cerberus?

I don’t think RLPext is available in RLPLite, it is a premium feature of the big RLP.


@ Architect - Still on the Cerberus, yes.

Ah… crap! It was used in the sample code from the Jeff provided. My bad.


No problem. :slight_smile:

By the way, what compiler/tools are you using to compile the rlp code?


I’m using Keil uVision v4.73 (the SW was mentioned in one of the tutorials)

Downloaded the eval a few days ago from here: