Cortex M3 OCM3U: Unterschied zwischen den Versionen

Aus der Mikrocontroller.net Artikelsammlung, mit Beiträgen verschiedener Autoren (siehe Versionsgeschichte)
Wechseln zu: Navigation, Suche
Zeile 218: Zeile 218:
| Bat.-Fassung
| Bat.-Fassung
| -
| -
| KZH-25-1 (Passende Batterie:CR 2477)
| KZH-12-1 (Passende Batterie:CR 1216)
|-
|-
| 1
| 1

Version vom 24. November 2008, 23:13 Uhr

von Theborg0815

ACHTUNG !!! Artikel in Arbeit.

OCM3U
OCM3U
OCM3U
OCM3U

Einleitung

Wer mal in die Welt der ST Cortex M3 schauen möchte, sollte sich das folgende Board mal anschauen. Es ist nichts Aufwendiges, nur das Wichtigste ist auf dem Board integriert. Aus Platzgründen habe ich auch den JTAG weggelassen, da der verwendete STM32F101 mit integriertem Bootloader daher kommt und sich über RS232 programmieren lässt, was für den Anfang reichen sollte. Zudem habe ich auch auf Sachen wie Spannungsregler und co. verzichtet, da hier jeder andere Vorstellungen hat. Zusätzlich ist es so gebaut, daß es auf ein Steckbrett passt.

Verbesserungen sind natürlich wie immer erwünscht.

--> Anmerkung: In den Diskussionsbereich verschoben, werde ich mich darum kümmern sobald ich die Zeit finde.

Features

  • Quarze für RTC und Hauptoszillator
  • wenig Extrabeschaltung
  • RS232 zum programmieren und für Datenübermittlung zum PC
  • STM32F101C8T6, 2.0-3.6V, 5V Tolerante I/Os, max. 36MHz, 32KB Flash, 6KB SRAM, 2x16Bit Timer, 2xSPI, 2xI2C, 3xUART, 10x12Bit ADC, 26xGPIOs, 1xRTC.
  • Größere Modelle im pinkompatiblen Gehäuse erhältlich

Software

Dieses kleine Beispiel schaltetet den Kompletten PortB

<c> /* Includes ------------------------------------------------------------------*/

  1. include "stm32f10x_it.h"

/* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ GPIO_InitTypeDef GPIO_InitStructure; ErrorStatus HSEStartUpStatus;

/* Private function prototypes -----------------------------------------------*/ void RCC_Configuration(void); void NVIC_Configuration(void); void Delay(vu32 nCount);

/* Private functions ---------------------------------------------------------*/

/*******************************************************************************

  • Function Name  : main
  • Description  : Main program.
  • Input  : None
  • Output  : None
  • Return  : None
                                                                                                                                                              • /

int main(void) {

  1. ifdef DEBUG
 debug();
  1. endif
 /* Configure the system clocks */
 RCC_Configuration();
   
 /* NVIC Configuration */
 NVIC_Configuration();
 /* Enable GPIOB clock */
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
 
 /* Configure PB.0 as Output push-pull */
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
 GPIO_Init(GPIOB, &GPIO_InitStructure);
 while (1)
 {
   /* Turn on led connected to PB.0 pin */
   GPIO_SetBits(GPIOB, GPIO_Pin_All);
   /* Insert delay */
   Delay(0xFFFFF);
   /* Turn off led connected to PB.0 pin */
   GPIO_ResetBits(GPIOB, GPIO_Pin_All);
   /* Insert delay */
   Delay(0xFFFFF);
 }

}

/*******************************************************************************

  • Function Name  : RCC_Configuration
  • Description  : Configures the different system clocks.
  • Input  : None
  • Output  : None
  • Return  : None
                                                                                                                                                              • /

void RCC_Configuration(void) {

 /* RCC system reset(for debug purpose) */
 RCC_DeInit();
 /* Enable HSE */
 RCC_HSEConfig(RCC_HSE_ON);
 /* Wait till HSE is ready */
 HSEStartUpStatus = RCC_WaitForHSEStartUp();
 if(HSEStartUpStatus == SUCCESS)
 {
   /* Enable Prefetch Buffer */
   FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
   /* Flash 2 wait state */
   FLASH_SetLatency(FLASH_Latency_2);
	
   /* HCLK = SYSCLK */
   RCC_HCLKConfig(RCC_SYSCLK_Div1); 
 
   /* PCLK2 = HCLK */
   RCC_PCLK2Config(RCC_HCLK_Div1); 
   /* PCLK1 = HCLK/2 */
   RCC_PCLK1Config(RCC_HCLK_Div2);
   /* PLLCLK = 8MHz * 4 = 32 MHz */
   RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_4);
   /* Enable PLL */ 
   RCC_PLLCmd(ENABLE);
   /* Wait till PLL is ready */
   while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
   {
   }
   /* Select PLL as system clock source */
   RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
   /* Wait till PLL is used as system clock source */
   while(RCC_GetSYSCLKSource() != 0x08)
   {
   }
 }

}

/*******************************************************************************

  • Function Name  : NVIC_Configuration
  • Description  : Configures Vector Table base location.
  • Input  : None
  • Output  : None
  • Return  : None
                                                                                                                                                              • /

void NVIC_Configuration(void) {

  1. ifdef VECT_TAB_RAM
 /* Set the Vector Table base location at 0x20000000 */ 
 NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); 
  1. else /* VECT_TAB_FLASH */
 /* Set the Vector Table base location at 0x08000000 */ 
 NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   
  1. endif

}

/*******************************************************************************

  • Function Name  : Delay
  • Description  : Inserts a delay time.
  • Input  : nCount: specifies the delay time length.
  • Output  : None
  • Return  : None
                                                                                                                                                              • /

void Delay(vu32 nCount) {

 for(; nCount != 0; nCount--);

}

  1. ifdef DEBUG

/*******************************************************************************

  • Function Name  : assert_failed
  • Description  : Reports the name of the source file and the source line number
  • where the assert_param error has occurred.
  • Input  : - file: pointer to the source file name
  • - line: assert_param error line source number
  • Output  : None
  • Return  : None
                                                                                                                                                              • /

void assert_failed(u8* file, u32 line) {

 /* User can add his own implementation to report the file name and line number,
    ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
 /* Infinite loop */
 while (1)
 {
 }

}

  1. endif

</c>

Bauteilliste

Stück Wert Bauteile Bauform Reichelt Bestellnummer
4 22pF Kondensator 0805 NPO-G0805 22P
5 100nF Kondensator 0805 X7R-G0805 100N
1 - Bat.-Fassung - KZH-12-1 (Passende Batterie:CR 1216)
1 - MAX3232ECWE SO16L -
2 - Pinheader 1x16 - 1x SL 1X36G 2,54
1 32.768Khz Crystal HC49UP -
1 8Mhz Crystal HC49UP 8,0000-HC49-SMD
1 - Switch - TASTER 9312
1 - STM32F101C8T6 LQFP48 -
1 - SUBD-CON. F09HP D-SUB BU 09US
Work in Prozess !!!

Downloads

Siehe auch

  • Diskussion zu diesem Projekt: NA

Links