:: Re: [DNG] Lua
Página Principal
Delete this message
Reply to this message
Autor: karl
Data:  
Para: dng
Assunto: Re: [DNG] Lua
olbigtenor:
> On Sat, Oct 19, 2024 at 6:10 AM <karl@???> wrote:

...
> > What do you want, programming for microcontrollers or for a pc getting
> > data from microcontrollers ?
> >
> (Utilizing one of the vagaries of the Hinglish (english) language - - )


Hinglish, is that hispanic + english ?
Here we have swinglish...

> yes


ok, at the mcu side. Mcus have nice litte pageturners describing how
they do their thing, take stm32f100 as an example:
http://www.st.com/resource/en/datasheet/stm32f100rc.pdf
https://www.st.com/resource/en/reference_manual/cd00246267-stm32f100xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf
very good to keep handy when you are bored and need some inspiration.

on datasheet p.34 there is a memory map and you can see that port A is
at address 0x40010800. The actual register for port A is described in
the reference manual at page 113, and one can see that there are a few
mode's and cnf's, one for each mcu gpio pin, e.g. mode5 and cnf5 is for
port PA5, which you can find on datasheet p.25 to be actual pin 25 for
the LQFP64 package.

To describe that in software, at least in C, there are two ways,

via defines or const ints:
https://github.com/libopencm3/libopencm3/blob/master/include/libopencm3/stm32/f1/gpio.h
use line 49, and 533 to get the register base address, then use
lines 610 to 645 to get cnf/mode bits and lastly shift that up 20 bits.
and write to the register to set up PA5.

via structs and bitfields:
https://github.com/STMicroelectronics/cmsis_device_f1/blob/master/Include/stm32f100xb.h
look at line 327-336, 1452-1666, seems ST didn't bother with bitfields.

for a bitfield example see line 265-285:
https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/Core/Include/core_cm3.h
The problem with bitfields is that they depends on the mcu's endianess.

I guess you do basically the same stuff in ADA.
Yes it is messy and I guess that is why the commersial tool
vendors have guis to configure such things.

Coding the mcu is just a matter of reading and writing a bunch of
registers :)

Example code in:
https://aspodata.se/git/openhw/boards_arm_aspo/stm32f105_can/arm_can_test.c

///

on the PC side, you use a serial port like rs232, rs485, can or
a derived field bus to talk to the mcu.
For rs232 you open the port set the termios things, and possible set
up your signal callbackss and poll()-stuff. See e.g.
https://aspodata.se/git/c/libaspoutil/tty_open.c

For CAN, you use socketcan.
https://en.wikipedia.org/wiki/SocketCAN

> (LOL - - - thank you for your generous assistance!)


You are welcome.

Regards,
/Karl Hammar