3
\$\begingroup\$

I'm a mechatronics (mechanical and electrical) engineering student and want to learn how to program ARM microprocessors. I've used Atmel ATMegas previously. I'm using a mac and being a student I don't want to use expensive software so I've installed eclipse, Yagarto and openocd as per this blog post. What I want to know though, is where do I get header files for individual chips, as I want to program in C not assembly?.

I'm planning on using STM32 chips as these and NXP's LPC chips seem to be the most popular and STM32 chips seem to be more advanced. I've found that there are some header files when they are part of development boards such as for the STM32F103RBT6 when part of STM32-H103 from Olimex but I can't seem to find header files for other chips in the same family.

A secondary question is, are there any tutorials for C programming of STM32 chips or Cortex-M based chips? I can't seem to find any tutorials that go through the basics such as blinking an LED.

asked Apr 18, 2013 at 10:03
\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

A good book that introduces Cortex-M3 based microcontrollers is "The definitve guide to the ARM Cortex-M3, Second Edition" written by Joseph Yiu. It contains both hardware and software explanations.

There's a software interface standard for Cortex-M processors that is called CMSIS (Cortex Microcontroller Interface Software). You can download standard pheripherals librairies from the microcontroller's manufacturer website which contains the CMSIS header files and source files.

You will also need a startup code to initialize your microcontroller before executing the main loop. It is usually provided by the IDE but I don't know if there's Eclipse packages that can do the job for you.

answered Apr 18, 2013 at 10:44
\$\endgroup\$
0
\$\begingroup\$

Here is a very simple program for flashing an LED on the STM32VLDISCOVERY board, which uses the STM32F100RB:

/* Test.c
** Simple program for STM32F100RB to flash LED on PC_9
**
*/
#include <stm32f10x.h>
void delay(void);
void main(void)
{
 // I/O port C clock enable
 RCC->APB2ENR = RCC_APB2ENR_IOPCEN;
 // Set PC_9 to output 
 GPIOC->CRH &= ~(GPIO_CRH_MODE9 | GPIO_CRH_CNF9);
 GPIOC->CRH |= GPIO_CRH_MODE9;
 while(1)
 {
 GPIOC->BSRR = (1<<9);
 delay();
 GPIOC->BRR = (1<<9);
 delay();
 }
}
void delay(void)
{
 volatile unsigned int i;
 for (i = 0; i < 20000; i++)
 ;
}
answered Apr 18, 2013 at 10:19
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.