Adventures with ARM CMSIS and the HAL

Status
Not open for further replies.

stevech

Well-known member
My first adventure with CMSIS on an $11@1ea ARM Cortex M4 chip is...

Code:
// called by main()
void myTest1(void)  {
  static uint32_t calls;
 
  ++calls;
  HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13); // toggle LED fast (MHz)
  if ((HAL_GetTick() & 511) == 511)  { // every half second
      HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_12); // toggle LED twice a second
      printf("%d ticks. Hello World. pass:%d\n", HAL_GetTick(), calls);
      calls = 0;
      while ((HAL_GetTick() & 511) == 511)
          ; //waste part of a mSec until next tick
  }
}

The printf() in the code says 960,000 calls per HALF-second.
EDIT: Optimized clock dividers. The above changed to 1.5M calls per half-second (153MHz core clock now).

First cut. I haven't checked if the clock dividers, etc., are optimally fast. I think I'm getting 96MHz core clock (of 168MHz max spec).
I like how clean and well documented (A++) CMSIS and the HAL are.
I'm more focused on assessing the M4 and CMSIS/HAL than on ARM vendor names, at the moment. E.g., UART, SPI, ADCs all have DMA options in the HAL drivers.

EDIT: enclosed: Screen grab from logic analyzer showing UART output.
2014-11-22_235727.jpg
 
Last edited:
My first adventure with CMSIS on an $11@1ea ARM Cortex M4 chip is...

Yes CMSIS is great, but there is a steep learning curve.
In 2010, i built a webradio with stm32, vs1053. This was the IR-Code: http://www.mikrocontroller.net/topic/166319
It is far for flexible than arduino but more complicated too. For a hobby, i like arduino more because with less effort gives faster results. With CMSIS you have better control of what is happening, Arduino "just works", with different mcu's, and the abstraction-level is higher. They are not comparable due to different line.
 
Last edited:
CMSIS...This was my first encounter with CMSIS and getting it going was very fast. The hard part of getting the startup.s and system startup C code - was automatically generated - using my pin and clocking choices. These choices were simplified to a half-hour's use of a GUI tool to designate choices. Excellent. THis degree of automation wasn't around in 2010.

I've used both Arduino/clone libraries and CMSIS and it's my view that CMSIS, after a slow start a few years back, is now much, much better for my purposes in the 32 bit world. This may not be true for some ARM vendors' CMSIS supplements, but the one I used was excellent.
 
Last edited:
In the 2 years since Teensy 3.0 was launched, ARM has incompatibly changed CMSIS at least a couple times. Hopefully it's stabilized now, but it sure would have been painful.

Arduino Due is based on an old CMSIS. It'll be interesting to see what the Arduino devs do with CMSIS as they make more ARM-based boards....
 
The CMSIS users (industry) and the Arduino users (hobby/student) are worlds apart. Two or so years ago, I looked at CMSIS and saw it was too sparse. Not so now, at least it is from the vendor I've assessed of late. As in the one sentence near the end of post #1 here - about even having DMA as an option.

I think Ardunio devs should concentrate on API wrappers for CMSIS libraries. This would make the life-cycle of libraries much more practical and prompt.
But creating a fork is hard.
 
Last edited:
I'm not sure if the DMA options are really viable. I've struggled a bit with the external GPIO interrupts, and if they screwed up DMA usage for the more complex peripherals in a similar way, I'll not touch that, but write my own DMA drivers instead.
 
I'm not sure if the DMA options are really viable. I've struggled a bit with the external GPIO interrupts, and if they screwed up DMA usage for the more complex peripherals in a similar way, I'll not touch that, but write my own DMA drivers instead.

What's not right with DMA? I've not tried it. I don't think I'd use DMA for other than ADCs. No SD card or ethernet planned.
 
There's nothing specifically wrong with DMA, but their external interrupts handler implementation is so crappy that I'm too scared to try their DMA implementation for, say, SPI. I'll write more later when I'm in the mood to explain things more thoroughly.
 
Yes i remember that this was a bit tricky.. i used spi-dma for thee devices: a "FlashRAM" , vs1053 and Ethernet..
 
Status
Not open for further replies.
Back
Top