This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bugs M0 M1 M4

Hi.
Sorry my English, "google" style :)
Found bugs in the Cortex M0, M3, M4 series controllers STMicroelectronics brand. I’m a hobbyist, so far I’m only using chips from this company.
I ask the question here because the bug appears in the handler mode, not in thread mode, and because I have already asked the question of the st-community and received such an answer:"What is wrong about it? What should it do instead, and why?" :) :)
For STM32VLDISCOVERY board with stm32f100RB chip assembler code is:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;STM32VLDISCOVERY board
;Clock: HSI 8MHz
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				GET		../inc/stm32f100x.asm


Stack_Size		*		0x00000400


				AREA	Stack,NOINIT,READWRITE
Stack_Mem		%		Stack_Size
__initial_sp


				AREA Reset,CODE,READONLY
				EXPORT	__Vectors
__Vectors
				&     __initial_sp
				&	  Reset_Handler
                &     NMI_Handler_
                &     HardFault_Handler_
                &     MemManage_Handler_
                &     BusFault_Handler_
                &     UsageFault_Handler_
                &     0
                &     0
                &     0
                &     0
                &     SVC_Handler_
                &     DebugMon_Handler_
                &     0
                &     PendSV_Handler_
                &     SysTick_Handler_


                &     WWDG_IRQ_					;1		#0x00			#0x00
                &     PVD_IRQ_					;2						#0x01
                &     TAMPER_IRQ_				;4						#0x02
                &     RTC_IRQ_					;8						#0x03
                &     FLASH_IRQ_				;16						#0x04
                &     RCC_IRQ_					;32						#0x05
                &     EXTI0_IRQ_				;64						#0x06
                &     EXTI1_IRQ_				;128					#0x07
                &     EXTI2_IRQ_				;1		#0x01			#0x08		
                &     EXTI3_IRQ_				;2						#0x09
                &     EXTI4_IRQ_				;4						#0x0A
                &     DMA1_Channel1_IRQ_		;8						#0x0B
                &     DMA1_Channel2_IRQ_		;16						#0x0C
                &     DMA1_Channel3_IRQ_		;32						#0x0D
                &     DMA1_Channel4_IRQ_		;64						#0x0E
                &     DMA1_Channel5_IRQ_		;128					#0x0F
                &     DMA1_Channel6_IRQ_		;1		#0x02			#0x10
                &     DMA1_Channel7_IRQ_		;2						#0x11
                &     ADC1_IRQ_					;4						#0x12
                &     0
                &     0
                &     0
                &     0
                &     EXTI9_5_IRQ_				;128					#0x17
                &     TIM1_BRK_TIM15_IRQ_		;1	#0x03				#0x18
                &     TIM1_UP_TIM16_IRQ_		;2						#0x19
                &     TIM1_TRG_COM_TIM17_IRQ_	;4						#0x1A
                &     TIM1_CC_IRQ_				;8						#0x1B
                &     TIM2_IRQ_					;16						#0x1C
                &     TIM3_IRQ_					;32						#0x1D
                &     TIM4_IRQ_					;64						#0x1E
                &     I2C1_EV_IRQ_				;128					#0x1F
                &     I2C1_ER_IRQ_				;1		#0x04			#0x20
                &     I2C2_EV_IRQ_				;2						#0x21
                &     I2C2_ER_IRQ_				;4						#0x22
                &     SPI1_IRQ_					;8						#0x23
                &     SPI2_IRQ_					;16						#0x24
                &     USART1_IRQ_				;32						#0x25
                &     USART2_IRQ_				;64						#0x26
                &     USART3_IRQ_				;128					#0x27
                &     EXTI15_10_IRQ_			;1		#0x05			#0x28
                &     RTCAlarm_IRQ_				;2						#0x29
                &     CEC_IRQ_					;4						#0x2A
                &     0
                &     0
                &     0
                &     0
                &     0
                &     0
                &     0
                &     0
                &     0
                &     0
                &     0
                &     TIM6_DAC_IRQ_				;64		#0x06			#0x36
                &     TIM7_IRQ_					;128					#0x37

				ALIGN

				AREA SysInit,CODE,READONLY
				ENTRY
				GLOBAL	Reset_Handler

Reset_Handler	PROC
				cpsid	i
				movs	r11,#1
				movs	r10,#0
;Enable port A,B,C, USART1 USART2 USART3
				ldr		r0,=RCC_CR
				movw	r1,#0x401C
				strh	r1,[r0,#0x18]
				movs	r1,#2_110
				strb	r1,[r0,#0x1E]
;Change APB2 prescaler in range 1...16
				movs	r1,#2_00101000
				strb	r1,[r0,#0x05]
;Pin PC9 as OUT in Push-Pull 2 MHz mode
				mov32	r0,#GPIOC_CRH
				mov32	r1,#0x44444424
				str		r1,[r0]

;;PA9:10 as TX:RX USART1 
				;ldr		r0,=GPIOA_CRH
				;ldr		r1,=0x88844AA4
				;str		r1,[r0]
;;USART1
				;ldr		r0,=USART1_SR
				;movw	r1,#0x2000
				;strh	r1,[r0,#0x0C]	;USART enable в CR1
				;movw	r1,#0xFFF0 ;341
				;strh	r1,[r0,#0x08]	;BRR
				;ldr		r0,=a_USART1_TE
				;str		r11,[r0]

;;PA2:3 as TX:RX USART2
				;ldr		r0,=GPIOA_CRL
				;ldr		r1,=0x4444AA44
				;str		r1,[r0]
;;USART2
				;ldr		r0,=USART2_SR
				;movw	r1,#0x2000
				;strh	r1,[r0,#0x0C]	;USART enable в CR1
				;movw	r1,#0x341
				;strh	r1,[r0,#0x08]	;BRR
				;ldr		r0,=a_USART2_TE
				;str		r11,[r0]

;PB10:11 as TX:RX USART3
				ldr		r0,=GPIOB_CRH
				ldr		r1,=0x4444AA44
				str		r1,[r0]
;USART3
				ldr		r0,=USART3_SR
				movw	r1,#0x2000
				strh	r1,[r0,#0x0C]	;USART enable в CR1
				movw	r1,#0x0341
				strh	r1,[r0,#0x08]	;baud rate 9.6KBps
				ldr		r0,=a_USART3_TE
				str		r11,[r0]

;Configure external interrupt on rising edge pin A0
				ldr		r0,=NVIC_ISER0
				movs	r3,#64
				strb	r3,[r0]
				ldr		r0,=EXTI_IMR
				str		r11,[r0]
				str		r11,[r0,#0x08]
				cpsie	i

;;Thread mode
				;ldr		r3,=GPIOA_IDR
;waitePress_A0
				;ldr		r1,[r3]
				;lsls	r1,#31
				;BEQ		waitePress_A0
				;ldr		r0,=USART3_DR
				;movs	r1,#'R'
				;strh	r1,[r0]			;send 'R' on USART3
				;ldr		r0,=GPIOC_BSRR	;;;;;;;;;;;;;;;;;;;;;;;;
				;movw	r1,#0x200		;
				;str		r1,[r0]			;
				;mov32	r2,#0x7A1200	;	LED on pin C9 is lit
;ledC9_ON								;
				;subs	r2,#1			;	withing 3 seconds 
				;BNE		ledC9_ON		;	*****************
				;lsl		r1,#16			;
				;str		r1,[r0]			;;;;;;;;;;;;;;;;;;;;;;;;
				;B		waitePress_A0

				B		.
				ALIGN
				ENDP

;Handler mode
EXTI0_IRQ_		PROC
				cpsid	i
				ldr		r0,=USART3_DR
				movs	r1,#'J'
				strh	r1,[r0]
				ldr		r0,=GPIOC_BSRR	;;;;;;;;;;;;;;;;;;;;;;;;
				movw	r1,#0x200		;
				str		r1,[r0]			;
				mov32	r2,#0x7A1200	;	LED on pin C9 is lit
LEDloop									;
				subs	r2,#1			;	withing ????? seconds 
				BNE		LEDloop			;	*********************
				lsl		r1,#16			;
				str		r1,[r0]			;;;;;;;;;;;;;;;;;;;;;;;;
				ldr		r0,=a_EXTI_PR0
				str		r11,[r0]	;clear interrapt flag in EXTI_PR0
				cpsie	i

				ldr		r12,[SP,#0x14]
				BX		LR
				ALIGN
				ENDP


NMI_Handler_			PROC
					B       .
					ENDP
HardFault_Handler_	PROC
					B       .
					ENDP
MemManage_Handler_	PROC
					B       .
					ENDP
BusFault_Handler_	PROC
					B       .
					ENDP
UsageFault_Handler_	PROC
					B       .
					ENDP
SVC_Handler_	PROC
					B       .
					ENDP
DebugMon_Handler_	PROC
					B       .
					ENDP
PendSV_Handler_	PROC
					B       .
					ENDP
SysTick_Handler_	PROC
					B       .
					ENDP

defolt_handler_		PROC

WWDG_IRQ_
PVD_IRQ_
TAMPER_IRQ_
RTC_IRQ_
FLASH_IRQ_
RCC_IRQ_
;EXTI0_IRQ_
EXTI1_IRQ_
EXTI2_IRQ_
EXTI3_IRQ_
EXTI4_IRQ_
DMA1_Channel1_IRQ_
DMA1_Channel2_IRQ_
DMA1_Channel3_IRQ_
DMA1_Channel4_IRQ_
DMA1_Channel5_IRQ_
DMA1_Channel6_IRQ_
DMA1_Channel7_IRQ_
ADC1_IRQ_
EXTI9_5_IRQ_
TIM1_BRK_TIM15_IRQ_
TIM1_UP_TIM16_IRQ_
TIM1_TRG_COM_TIM17_IRQ_
TIM1_CC_IRQ_
TIM2_IRQ_
TIM3_IRQ_
TIM4_IRQ_
I2C1_EV_IRQ_
I2C1_ER_IRQ_
I2C2_EV_IRQ_
I2C2_ER_IRQ_
SPI1_IRQ_
SPI2_IRQ_
USART1_IRQ_
USART2_IRQ_
USART3_IRQ_
EXTI15_10_IRQ_
RTCAlarm_IRQ_
CEC_IRQ_
TIM6_DAC_IRQ_
TIM7_IRQ_
                B       .
				
				ALIGN
				ENDP

				END

In the tread mode code block:

			    mov32	r2,#0x7A1200	;	LED on pin C9 is lit
ledC9_ON								;
				subs	r2,#1			;	withing 3 seconds 
				BNE		ledC9_ON		;	*****************

runs in 3 sec. USART does not have abnormal behavior.

In handler mode, external interrupt EXTI0, also it's ok if APB2 prescaler is 0 or 2. BUT if APB2 prescaler is 4 or higher the mentioned above code runs in 6 sec and USART, in one byte mode, sents byte TWICE.
I found these bugs on chip stm32f100RB rev Z, stm32f030f4 rev A, stm32f051C8 rev B. But two last chips, cortex-M0 arc run code for 4 second in thread mode.

Chip stm32f303VC rev Y (STM32F3DISCOVERY board) has little different behavior. It's bugs appear for all value APB2 prescaler.

СПС

Parents Reply Children
No data