Forum: Mikrocontroller und Digitale Elektronik STM8 / Cosmic / ST Visual Develop error


von Thomas (Gast)


Lesenswert?

Hallo,

ich mache gerade die ersten Gehversuche mit einem STM8S103. Ich habe mir 
ST Visual Develop installiert, den kostenlosen 8kB Cosmiq Compiler 
installiert und eine LED zum blinken gebracht (mit delay :-D).

Jetzt habe ich mir aus den Libs einige Beispiel zusammen kopiert. Ich 
habe eine PWM konfiguriert (aus dem Beispiel übernommen) und wollte zum 
Debuggen einen UART nutzen.

Alleine Funktionieren beide Funktionen. Leider bekomme ich die 
Fehlermeldung

#error clnk Debug\stm8s103_pro.lkf:1 segment .text size overflow

wenn ich beide zusammen nutzen möchte.

Lösche ich den Timer2 kann ich bauen und im map file steht schon ein 
relativ hoher wert von 5599. Sind das kb? Ist der Speicher von 8kB schon 
voll? Kann ich mir kaum vorstellen. Was mache ich falsch?

Vielen Dank.!
1
Map of Debug\stm8s103_pro.sm8 from link file Debug\stm8s103_pro.lkf - Mon Nov 13 23:38:57 2017
2
3
4
                               --------
5
                               Segments
6
                               --------
7
8
start 00008080 end 00008128 length   168 segment .const
9
start 0000812b end 0000970a length  5599 segment .text
10
start 00004000 end 00004000 length     0 segment .eeprom
11
start 00000000 end 00000000 length     0 segment .bsct
12
start 00000000 end 0000000a length    10 segment .ubsct
13
start 0000000a end 0000000a length     0 segment .bit
14
start 0000000a end 0000000a length     0 segment .share
15
start 00000100 end 00000100 length     0 segment .data
16
start 00000100 end 00000100 length     0 segment .bss
17
start 00000000 end 000008a1 length  2209 segment .info.
18
start 00000000 end 00005b2d length 23341 segment .debug
19
start 00008000 end 00008080 length   128 segment .const
20
start 00008128 end 0000812b length     3 segment .init
1
#include "stm8s.h"
2
#include "stdio.h"
3
4
void Delay (uint16_t nCount);
5
6
// UART
7
#ifdef _RAISONANCE_
8
#define PUTCHAR_PROTOTYPE int putchar (char c)
9
#define GETCHAR_PROTOTYPE int getchar (void)
10
#elif defined (_COSMIC_)
11
#define PUTCHAR_PROTOTYPE char putchar (char c)
12
#define GETCHAR_PROTOTYPE char getchar (void)
13
#else /* _IAR_ */
14
#define PUTCHAR_PROTOTYPE int putchar (int c)
15
#define GETCHAR_PROTOTYPE int getchar (void)
16
#endif /* _RAISONANCE_ */
17
18
void main(void)
19
{
20
  uint16_t CCR3_Val = 5;
21
  
22
  // UART definition
23
  char ans;
24
  CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);   // High speed internal clock prescaler: 1
25
  UART1_DeInit(); 
26
  /* UART1 configuration ------------------------------------------------------*/
27
  /* UART1 configured as follow:
28
        - BaudRate = 115200 baud  
29
        - Word Length = 8 Bits
30
        - One Stop Bit
31
        - No parity
32
        - Receive and transmit enabled
33
        - UART1 Clock disabled
34
  */
35
  UART1_Init((uint32_t)115200, UART1_WORDLENGTH_8D, UART1_STOPBITS_1, UART1_PARITY_NO,
36
              UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE);
37
38
  
39
40
  // PWM output  
41
  TIM2_TimeBaseInit(TIM2_PRESCALER_1, 99); //Time base configuration
42
  TIM2_OC3Init(TIM2_OCMODE_PWM1, TIM2_OUTPUTSTATE_ENABLE,CCR3_Val, TIM2_OCPOLARITY_HIGH); //PWM1 Mode configuration: Channel3
43
  
44
  TIM2_OC3PreloadConfig(ENABLE);
45
  TIM2_ARRPreloadConfig(ENABLE);
46
  TIM2_Cmd(ENABLE); //TIM2 enable counter
47
48
49
  
50
  // init LED GPIO
51
  GPIO_Init(GPIOB, (GPIO_Pin_TypeDef)GPIO_PIN_5, GPIO_MODE_OUT_PP_LOW_FAST);
52
53
  while (1)
54
  {
55
    GPIO_WriteReverse(GPIOB, (GPIO_Pin_TypeDef)GPIO_PIN_5); // Toggles LED
56
    Delay(0xFFFF);
57
    
58
    ans = getchar();
59
    printf("%c", ans);  
60
61
  }
62
63
}
64
void Delay(uint16_t nCount)  
65
{
66
  /* Decrement nCount value */
67
  while (nCount != 0)
68
  {
69
    nCount--;
70
  }
71
}
72
73
PUTCHAR_PROTOTYPE
74
{
75
  /* Write a character to the UART1 */
76
  UART1_SendData8(c);
77
  /* Loop until the end of transmission */
78
  while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);
79
80
  return (c);
81
}
82
83
/**
84
  * @brief Retargets the C library scanf function to the USART.
85
  * @param None
86
  * @retval char Character to Read
87
  */
88
GETCHAR_PROTOTYPE
89
{
90
#ifdef _COSMIC_
91
  char c = 0;
92
#else
93
  int c = 0;
94
#endif
95
  /* Loop until the Read data register flag is SET */
96
  while (UART1_GetFlagStatus(UART1_FLAG_RXNE) == RESET);
97
    c = UART1_ReceiveData8();
98
  return (c);
99
}
100
101
#ifdef USE_FULL_ASSERT
102
103
/**
104
  * @brief  Reports the name of the source file and the source line number
105
  *   where the assert_param error has occurred.
106
  * @param file: pointer to the source file name
107
  * @param line: assert_param error line source number
108
  * @retval None
109
  */
110
void assert_failed(uint8_t* file, uint32_t line)
111
{ 
112
  /* User can add his own implementation to report the file name and line number,
113
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
114
115
  /* Infinite loop */
116
  while (1)
117
  {
118
  }
119
}
120
#endif
121
122
/**
123
  * @}
124
  */
125
126
127
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

von Philipp Klaus K. (pkk)


Lesenswert?

Thomas schrieb:
> Lösche ich den Timer2 kann ich bauen und im map file steht schon ein
> relativ hoher wert von 5599. Sind das kb? Ist der Speicher von 8kB schon
> voll? Kann ich mir kaum vorstellen. Was mache ich falsch?

Die Werte sind Bytes. Dann kommen die beiden .const auch noch in den 
flash. Was .info ist, weiß ich nicht, aber wenn das auch in dem Flash 
kommt, bist Du schon über 8 kB.

Dein Code sieht allerdings nicht so aus, als sollte er so groß sein. 
Stehen im .map noch mehr Details dazu, wie sich .text auf die einzelnen 
Funktionen aufteilt?

Philipp

von ./. (Gast)


Lesenswert?

Eventuell koennte es was bringen, die "Libs" auch wirklich
zu einer ".lib" zu kompilieren und ganz zum Schluss
dazuzulinken.
Beim kostenfreien (Kickstart-)IAR-Compiler gibt es z.B.
fuer dazugelinkte Libs m.W. keine Groessenbeschraenkung.

von Third E. (third-eye)


Lesenswert?

Ich nutze auch den Cosmic-Compiler und STVD.
Die kryptische Meldung "segment .text size overflow" bekommt man, wenn 
das Kompilat zu groß für den Flash-Speicher ist.

Ich nutze srec2bin, um mir die Größe der s19-Datei anzeigen zu lassen:
http://www.s-record.com/

Der Befehl wird bei mir nach dem Kompilieren automatich ausgeführt:
srec2bin.exe -o 8000 Kompilat.s19 NUL 2>&1

: Bearbeitet durch User
von Axel S. (a-za-z0-9)


Lesenswert?

Third E. schrieb:
> Die kryptische Meldung "segment .text size overflow" bekommt man, wenn
> das Kompilat zu groß für den Flash-Speicher ist.

Was ist daran kryptisch? Daß das Segment für den Programmcode den 
Namen Textsegment hat? Das ist historisch bedingt.

von Thomas (Gast)


Lesenswert?

Hallo Leute,

Danke für euere Tips. Ich habe einen Hinweis gefunden. Der Cosmic 
Compiler ist standardmäßig so eingestellt, dass er nicht benutzte 
Funktionen nicht rausschmeißt :-((((

Die Option split im Compiler bewirkt Wunder und der Code ist zu mindest 
nur noch halb so groß. Verwunderlich finde ich es aber immer noch. 
Vielleicht muss ich doch weg von der std lib... 8 kB habe ich glaube 
noch nie mit C Code vollbekommen....

Hier war die Lösung:
https://www.cosmicsoftware.com/pdf/optiST7.PDF
Folie 13

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.