ARM 16 bit Input Outbut and mult

An area to discuss ARM specific problems and examples

Moderator: Benj

Post Reply
PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times
Contact:

ARM 16 bit Input Outbut and mult

Post by PicoPuls »

Is it possible to read PA0....PA15 into one single variable,

I guess you would call these two bytes UInt

Is it possible to multiply two UInt-s ?

Is it possible to output PB0....PB15 from one single UInt variable ?

Is it possible to store hundreds of such UInt measurements into the large ARM memory

Best regards
BO

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: ARM 16 bit Input Outbut and mult

Post by LeighM »

Is it possible to read PA0....PA15 into one single variable,
Yes, read the port halves as bytes and then form the uint result
uint.jpg
uint.jpg (14.43 KiB) Viewed 6751 times
You could do it faster with C code

Code: Select all

FCV_UINTVAL = GPIOA->IDR;
Is it possible to multiply two UInt-s ?
Yes, but you would need a ULONG result
Is it possible to output PB0....PB15 from one single UInt variable ?
Similar to the read, you could do this in two bytes.
You could also do this as C code (but you would first need to set the port to output mode) ...

Code: Select all

GPIOB->ODR = FCV_UINTVAL;
Is it possible to store hundreds of such UInt measurements into the large ARM memory
Yes, just create a UINT array in Flowcode by adding its size: array[1000]
Last edited by LeighM on Tue Apr 25, 2017 12:49 pm, edited 1 time in total.

PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times
Contact:

Re: ARM 16 bit Input Outbut and mult

Post by PicoPuls »

Very helpful, thanks !

Would it be possible to transfer such a big measurement array over UART -USB serial communication
to a PC computer, and make this in the background, allowing the processor to work full speed
collecting the next array ?

I think that the hardware UART also has a hardware buffer that might be of help.

Best regards
BO

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ARM 16 bit Input Outbut and mult

Post by Benj »

Hello,

The easy way would be to use a circular buffer to store the data as you are sampling and then shift the data out on a regular basis using a transmit interrupt or a timer interrupt.

The harder yet more capable way would be to use DMA to do the shifting out for you. However I would imagine this would require a lot of playing around and C code. As far as I know it's not something we have played with so we wouldn't be able to advise on this and you may have to start reading the various documentation and examples to get to grips with this.

A Flowcode DMA component would be ideal but from playing with DMA in the past I know its an absolute can of worms and really hard to do right and cover all bases. Still as a scientist anything is possible :lol: .

We have a resident ST Arm expert who may know more about these types of thing but he is currently away on holiday. I will ask him about it when he gets back to see what he would advise. Leigh may also know more but he is pretty snowed under at the moment with other projects.

Post Reply