STM32F4-Discovery RS232 über USB

Gast #2819930
Lesenswert?

Hallo!

Ich versuche gerade ein HelloWorld! mit dem STM32F4-Discovery zu 
schreiben, konkret die USB Schnittstelle als Debug-Schnittstelle zu 
verwenden.

Ich versuche ein RS232 Gerät vorzugaukeln, um ein normales Terminal zu 
verwenden.

Dieses erscheint mir bis jetzt am sinnvollsten:
https://www.das-labor.org/trac/browser/microcontroller/src-stm32f4xx

Ich schaff es aber nicht, dieses in der CooCox IDE zum laufen zu 
bringen. Welche Libary brauch genau dafür und wie bind ich diese ein, 
dass ich nicht alle Pfade für jede einzelne Datei setzen zu müssen?

Vllt hat auch jemand einen besseren Link/Anleitung für mich?


MfG
F.
Gast #2820575
Lesenswert?

ich habs jetzt manuell über das makefile per hand probiert, komischer 
weiße findet er dann die .h files nicht, welche im gleichen directory 
wie das makefile liegen, das kann ja eigenlich gar nicht sein, oder?

aber eigentlich müsste das ja auch über die coocox IDE funktioniern?

muss ich per hand einstellen, wo die .h files liegen?

hab bis jetz nur mit dem java complier erfahrung, da hab ich mich nicht 
um Headerfiles kümmern müssen.

mfg
f.
Gast #2820591
Lesenswert?

fluttershy schrieb:
> Ich versuche gerade ein HelloWorld! mit dem STM32F4-Discovery zu
> schreiben, konkret die USB Schnittstelle als Debug-Schnittstelle zu
> verwenden.

Das ist ein klitzekleines bisschen mehr als Helloworld. Helloworld wäre 
eher eine LED blinken lassen. USB-Bastelei ist schon ziemlich 
kompliziert. Das Discovery hat ja eingebaute Debug-Funktionalität, da 
kannste dir auch ohne printf anschauen, was der µC macht. Oder einen der 
USART's aufm µC nehmen, und einen USB->RS232 Adapter dranhängen...
Gast #2820601
Lesenswert?

ok, war vllt übertrieben mit dem hello world, aber mit dem  Atmega hab 
ich sowas auch schon zusammengebracht...

ich will ja nix neues entwickeln, sondern was funktionierendes in meiner 
ide zum laufen bringen. ich weiß nur nicht wie ich dieser beibringen 
soll, wo meine .h files liegen ..
#2820751
Lesenswert?

um eine einfache debug ausgabe mit der uart zu realiseren mach einfach 
ein printf via uart:

1. Initialisiere deine UARTx
2. Übernimm diese main.c und ergänze den Header:
voila

ohne DMA  , ohne Interrupt
1
/**
2
  ******************************************************************************
3
  * @file    main.c
4
  * @author  EGü
5
  * @version V1
6
  * @date    29.08.2012
7
  * @brief   Main program body
8
  */  
9
  
10
/* Includes ------------------------------------------------------------------*/
11
#include "stm32f10x.h"
12
#include "main.h"
13
#include <stdio.h>
14
/* Private constants ---------------------------------------------------------*/
15
char ReceivedData = NULL;
16
/* Private function prototypes -----------------------------------------------*/
17
#ifdef __GNUC__
18
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
19
   set to 'Yes') calls __io_putchar() */
20
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
21
#else
22
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
23
#endif /* __GNUC__ */
24
/* Main Routine ---------------------------------------------------------*/
25
int main(void)
26
{
27
SystemInit();
28
  /* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */
29
  RCC_APB2PeriphClockCmd(  RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC
30
              | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE );
31
  
32
  
33
  UARTInit();
34
    while(1) { 
35
    printf("TEST TEST TEST ");
36
      }
37
  }
38
  
39
void UARTInit()
40
{
41
  /* USARTx configured as follow:
42
        - BaudRate = 115200 baud  
43
        - Word Length = 8 Bits
44
        - One Stop Bit
45
        - No parity
46
        - Hardware flow control disabled (RTS and CTS signals)
47
        - Receive and transmit enabled
48
  */
49
  USART_InitTypeDef USART_InitStructure;
50
  USART_InitStructure.USART_BaudRate = 115200;
51
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
52
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
53
  USART_InitStructure.USART_Parity = USART_Parity_No;
54
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
55
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
56
  COMInit(USART2, &USART_InitStructure); //bei dir heißt das anders!  
57
}
58

59

60
/**
61
  * @brief  Retargets the C library printf function to the USART.
62
  * @param  None
63
  * @retval None
64
  */
65
PUTCHAR_PROTOTYPE
66
{
67
  /* Place your implementation of fputc here */
68
  /* e.g. write a character to the USART */
69
  USART_SendData(USART2, (uint8_t) ch);
70

71
  /* Loop until the end of transmission */
72
  while (USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET)
73
  {}
74

75
  return ch;
76
}
77

78
#ifdef  USE_FULL_ASSERT
79

80
/**
81
  * @brief  Reports the name of the source file and the source line number
82
  *         where the assert_param error has occurred.
83
  * @param  file: pointer to the source file name
84
  * @param  line: assert_param error line source number
85
  * @retval None
86
  */
87
void assert_failed(uint8_t* file, uint32_t line)
88
{ 
89
  /* User can add his own implementation to report the file name and line number,
90
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
91

92
  /* Infinite loop */
93
  while (1)
94
  {
95
  }
96
}
97
#endif

main.h
1
/**
2
  * @file    main.h
3
  * @author  EGü
4
  */
5

6
#ifndef __MAIN_H_
7
#define __MAIN_H_
8

9

10
#ifdef __cplusplus
11
extern "C" {
12
#endif
13

14

15
void UARTInit(void);
16

17

18
#ifdef __cplusplus
19
}
20
#endif
21

22
#endif /* __MAIN_H_ */


Hoffe das ich helfen konnte!

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren