Author Topic: low level ARM programming  (Read 7345 times)

0 Members and 1 Guest are viewing this topic.

Offline ralphdTopic starter

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: ca
    • Nerd Ralph
low level ARM programming
« on: October 08, 2015, 06:30:01 am »
Although I'll probably go the RTOS route, I started looming into how hard it would be to directly configure peripheral registers on the STM32F030 like I do with AVR MCUs.
The datasheet tells me which pins can be used for Tx and RX, but doesn't say anything about the USART registers.  The programmimg manual says where the 1KB block for the USART is mapped, but doesn't describe the registers.
Is this normal for ARM MCUs?  With the AVRs, one datasheet has everything you need to know.
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline richard_t

  • Newbie
  • Posts: 4
  • Country: gb
Re: low level ARM programming
« Reply #1 on: October 08, 2015, 06:35:50 am »
You need to find the reference manual (ST document RM0360). You'll find it on the product page for your microcontroller under Design Resources.
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: low level ARM programming
« Reply #2 on: October 08, 2015, 06:39:08 am »
The datasheet contains information for the PCB layout guy. Such as: pin matrix, electrical and physical specifications.
The programming manual contains information for the RTOS and compiler guy. Such as: arm cortex details and how to use interrupts, exceptions and other low level stuff regarding the core.
The reference manual contains information for the peripheral driver guy. This is where you need to look.

An AVR is so supersimple that everything fits in a single thousand page datasheet. This does not apply to 32 bit anymore.
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: low level ARM programming
« Reply #3 on: October 08, 2015, 07:17:28 am »
There are multiple steps to use a STM32F pin:

  • Configure system clock (same as for any program)
  • enable power to the bus
  • set pin to input, output, or alt function
  • set output pin speed
  • set pull-up or pull-down (optional)

Now you are ready!! :-)
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6460
  • Country: nl
Re: low level ARM programming
« Reply #4 on: October 08, 2015, 07:30:48 am »
Is this normal for ARM MCUs?  With the AVRs, one datasheet has everything you need to know.
Yeah this is normal. The ARM core itself has at least three documents with hundreds of pages. Then there are differences between versions of the same core you need to know (sometimes) and then you only read about the core it self. You choose a manufacturer and then you read all the manufacturer documents as stated by others above.
Good thing is the ARM core documents are the same for all vendors, the bad thing, every vendor has its own peripherals and other WOW.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: low level ARM programming
« Reply #5 on: October 08, 2015, 07:59:32 am »
Although I'll probably go the RTOS route, I started looming into how hard it would be to directly configure peripheral registers on the STM32F030 like I do with AVR MCUs.
The datasheet tells me which pins can be used for Tx and RX, but doesn't say anything about the USART registers.  The programmimg manual says where the 1KB block for the USART is mapped, but doesn't describe the registers.
Is this normal for ARM MCUs?  With the AVRs, one datasheet has everything you need to know.
Yes. Look for a datasheet with electrical specs and a user/programming manual on how to make a program for it. Besides that always check the errata sheet!
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline commie

  • Frequent Contributor
  • **
  • Posts: 278
  • Country: gb
Re: low level ARM programming
« Reply #6 on: October 08, 2015, 11:16:09 am »
ugg..sounds terrible. :scared:
 

Offline ralphdTopic starter

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: ca
    • Nerd Ralph
Re: low level ARM programming
« Reply #7 on: October 08, 2015, 01:07:48 pm »
The reference manual contains information for the peripheral driver guy. This is where you need to look.

An AVR is so supersimple that everything fits in a single thousand page datasheet. This does not apply to 32 bit anymore.
Or for some AVRs like the tiny13a, <200 pages.
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline ralphdTopic starter

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: ca
    • Nerd Ralph
Re: low level ARM programming
« Reply #8 on: October 08, 2015, 02:06:07 pm »
Reading the F030 reference manual.  Compicated but powerful.  For example the RTC can be calibrated down to 1ppm.  It also has an onboard CRC engine.  Impressive set of features for a chip that costs around 50c in small qty...
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: low level ARM programming
« Reply #9 on: October 08, 2015, 02:16:55 pm »
Is this normal for ARM MCUs?  With the AVRs, one datasheet has everything you need to know.

It's not just an ARM thing, it's a "modern MCU" thing. AVR XMEGAs are split into datasheet and reference manual as well. Not sure how I feel about that, really. :-\
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7547
  • Country: 00
  • +++ ATH1
Re: low level ARM programming
« Reply #10 on: October 08, 2015, 02:21:28 pm »
The reference manual contains information for the peripheral driver guy. This is where you need to look.

An AVR is so supersimple that everything fits in a single thousand page datasheet. This does not apply to 32 bit anymore.
Or for some AVRs like the tiny13a, <200 pages.

I've learned my lesson too when it comes to bare metal ARM programming, the datasheet details starting from the ARM core and it's details, down to the unique manufacturer's peripherals setting bit by bit, at few ARM's datasheets from different manufacturers , mostly are above 1000 pages.  ::)

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6460
  • Country: nl
Re: low level ARM programming
« Reply #11 on: October 08, 2015, 02:44:42 pm »
Yeah but do you need all that info?  :-//
Most people in our company that program on Arm's have never seen those Arm manuals. As long as you do the normal stuff you do not need it.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: low level ARM programming
« Reply #12 on: October 08, 2015, 03:06:09 pm »
Yeah but do you need all that info?  :-//
Most people in our company that program on Arm's have never seen those Arm manuals. As long as you do the normal stuff you do not need it.
True. When I program on Intel PC or Raspberry Pi, I don't need processor or chipset's manuals. ;)
« Last Edit: October 08, 2015, 03:08:36 pm by Kalvin »
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: low level ARM programming
« Reply #13 on: October 08, 2015, 06:02:51 pm »
As it happens, ARM has a (few) compiler(s) on it own. If you use that compiler, you'll find the quality documentation on their part.
http://infocenter.arm.com/help/index.jsp
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: low level ARM programming
« Reply #14 on: October 08, 2015, 08:48:48 pm »
As it happens, ARM has a (few) compiler(s) on it own. If you use that compiler, you'll find the quality documentation on their part.
http://infocenter.arm.com/help/index.jsp

For $8000, you would expect quality documentation  >:D.
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: low level ARM programming
« Reply #15 on: October 08, 2015, 11:24:08 pm »
(I don't think that "compiler documentation" is one of the things at question in this thread...)
Ralph: did you see this thread: https://www.eevblog.com/forum/microcontrollers/one-dollar-one-minute-arm-development/
There are a bunch of low-level issues discussed there, including some examples in (gasp) ARM assembly.
(Watch out, though.  While the assembler syntax is about the same, CM0 and CM3 are more dramatically different than you would think!  I think.)
 

Offline ralphdTopic starter

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: ca
    • Nerd Ralph
Re: low level ARM programming
« Reply #16 on: October 09, 2015, 03:23:38 am »
(I don't think that "compiler documentation" is one of the things at question in this thread...)
Ralph: did you see this thread: https://www.eevblog.com/forum/microcontrollers/one-dollar-one-minute-arm-development/
There are a bunch of low-level issues discussed there, including some examples in (gasp) ARM assembly.
(Watch out, though.  While the assembler syntax is about the same, CM0 and CM3 are more dramatically different than you would think!  I think.)
Hadn't seen it before.  Thanks... I think.  It's a long thread and so far the SNR is questionable.
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline ale500

  • Frequent Contributor
  • **
  • Posts: 415
Re: low level ARM programming
« Reply #17 on: October 09, 2015, 04:33:05 am »
You probably mean something like this... don't you ?
Code: [Select]
void hal_spi1_Init( void )
{
    LPC_SC->PCONP |= (1 << 10);     // SPI1 Power Enable
    LPC_SC->PCLKSEL0 &= ~(3 << 20); // Clear clock Bits
    LPC_SC->PCLKSEL0 |=  (1 << 20); // CLK / 1

    // Select MISO, MOSI, and SCK pin-select functionality
    LPC_PINCON->PINSEL0 &= ~( (3 << 14) | (3 << 16) | (3 << 18) );
    LPC_PINCON->PINSEL0 |=  ( (2 << 14) | (2 << 16) | (2 << 18) );

    LPC_SSP1->CR0 = 7;          // 8-bit mode
    LPC_SSP1->CR1 = 0;    // shut-down SSP1
    LPC_SSP1->CR1 = (1 << 1);   // Enable SSP as Master
    LPC_SSP1->CPSR = 8;         // SCK speed = CPU / 8
    LPC_GPIO0->FIODIR |= DSPI_SS; // Slave select
    LPC_GPIO0->FIOSET |= DSPI_SS; //

    // A0 and Reset lines
LPC_GPIO0->FIODIR |= DISP_A0 | DISP_RES;
LPC_GPIO0->FIOCLR |= DISP_A0 | DISP_RES;
}
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf