low level ARM programming - Page 1
Forum section: electronics / general

author: ralphd
author_rank: Frequent Contributor
timestamp: October 08, 2015, 06:30:01 am
content: 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.

author: richard_t
author_rank: Newbie
timestamp: October 08, 2015, 06:35:50 am
content: You need to find the reference manual (ST document RM0360). You'll find it on the product page for your microcontroller under Design Resources.

author: Jeroen3
author_rank: Super Contributor
timestamp: October 08, 2015, 06:39:08 am
content: 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 whereyouneed to look.An AVR is so supersimple that everything fits in a single thousand page datasheet. This does not apply to 32 bit anymore.

author: richardman
author_rank: Frequent Contributor
timestamp: October 08, 2015, 07:17:28 am
content: There are multiple steps to use a STM32F pin:Configure system clock (same as for any program)enable power to the busset pin to input, output, or alt functionset output pin speedset pull-up or pull-down (optional)Now you are ready!! :-)

author: Kjelt
author_rank: Super Contributor
timestamp: October 08, 2015, 07:30:48 am
content: Quote from: ralphd on October 08, 2015, 06:30:01 amYeah 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.

author: nctnico
author_rank: Super Contributor
timestamp: October 08, 2015, 07:59:32 am
content: Quote from: ralphd on October 08, 2015, 06:30:01 amYes. 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!

author: commie
author_rank: Frequent Contributor
timestamp: October 08, 2015, 11:16:09 am
content: ugg..sounds terrible.

author: ralphd
author_rank: Frequent Contributor
timestamp: October 08, 2015, 01:07:48 pm
content: Quote from: Jeroen3 on October 08, 2015, 06:39:08 amOr for some AVRs like the tiny13a, <200 pages.

author: ralphd
author_rank: Frequent Contributor
timestamp: October 08, 2015, 02:06:07 pm
content: 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...

author: c4757p
author_rank: Super Contributor
timestamp: October 08, 2015, 02:16:55 pm
content: Quote from: ralphd on October 08, 2015, 06:30:01 amIt'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.

author: BravoV
author_rank: Super Contributor
timestamp: October 08, 2015, 02:21:28 pm
content: Quote from: ralphd on October 08, 2015, 01:07:48 pmI'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.

author: Kjelt
author_rank: Super Contributor
timestamp: October 08, 2015, 02:44:42 pm
content: 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.

author: Kalvin
author_rank: Super Contributor
timestamp: October 08, 2015, 03:06:09 pm
content: Quote from: Kjelt on October 08, 2015, 02:44:42 pmTrue. When I program on Intel PC or Raspberry Pi, I don't need processor or chipset's manuals.

author: Jeroen3
author_rank: Super Contributor
timestamp: October 08, 2015, 06:02:51 pm
content: 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

author: richardman
author_rank: Frequent Contributor
timestamp: October 08, 2015, 08:48:48 pm
content: Quote from: Jeroen3 on October 08, 2015, 06:02:51 pmFor $8000, you would expect quality documentation.

author: westfw
author_rank: Super Contributor
timestamp: October 08, 2015, 11:24:08 pm
content: (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.)

author: ralphd
author_rank: Frequent Contributor
timestamp: October 09, 2015, 03:23:38 am
content: Quote from: westfw on October 08, 2015, 11:24:08 pmHadn't seen it before. Thanks... I think. It's a long thread and so far the SNR is questionable.

author: ale500
author_rank: Frequent Contributor
timestamp: October 09, 2015, 04:33:05 am
content: You probably mean something like this... don't you ?Code:void hal_spi1_Init( void ){LPC_SC->PCONP |= (1 << 10); // SPI1 Power EnableLPC_SC->PCLKSEL0 &= ~(3 << 20); // Clear clock BitsLPC_SC->PCLKSEL0 |= (1 << 20); // CLK / 1// Select MISO, MOSI, and SCK pin-select functionalityLPC_PINCON->PINSEL0 &= ~( (3 << 14) | (3 << 16) | (3 << 18) );LPC_PINCON->PINSEL0 |= ( (2 << 14) | (2 << 16) | (2 << 18) );LPC_SSP1->CR0 = 7; // 8-bit modeLPC_SSP1->CR1 = 0;// shut-down SSP1LPC_SSP1->CR1 = (1 << 1); // Enable SSP as MasterLPC_SSP1->CPSR = 8; // SCK speed = CPU / 8LPC_GPIO0->FIODIR |= DSPI_SS; // Slave selectLPC_GPIO0->FIOSET |= DSPI_SS; //// A0 and Reset linesLPC_GPIO0->FIODIR |= DISP_A0 | DISP_RES;LPC_GPIO0->FIOCLR |= DISP_A0 | DISP_RES;}