cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Discovery - Encoder Control Using Peripheral Drivers Problems

Posted on July 20, 2012 at 14:49

Hi everyone I'm also trying to do an encoder control unit with stm32f4 discovery using of the standard periphberal libriaries and I have two problems.

1-) When I want to build codes, there is an error occuring which is ;

Error : L6218E : Undefined symbol assert-param (referred from misc.o)

after that problem I researched about this error with it's Error Number and I found something. The answer of my problem was USE_STDPERIPH_DRIVER definition (at 'Configure Flash Tools' => 'C/C++' => 'Define' ). Then I applied it to my project but another error occured. I added second error's pic and project files. Thanks.
17 REPLIES 17
Posted on July 25, 2012 at 16:26

Hard to say, the problem isn't in the code presented, but could relate to the vector table, or how you have initialized the peripherals. ZIP up an example project, I'll take a look.

As for priority, the only time the sub-priority matters is the instant that both interrupts are asserted together (within the context setup), and the processor decides which to handle first. If you want one to interrupt the other you'll need to play with the preemption level.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 25, 2012 at 16:58

in misc.c, start line 159 end line Why enable and disable selections are doing the same operations? Or am I wrong?

void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)

{

.

...

...

...

...

NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;

/* Enable the Selected IRQ Channels --------------------------------------*/

NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); }

else

{

/* Disable the Selected IRQ Channels -------------------------------------*/

NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] = (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F); }

}

________________

Attachments :

STM32F4xx_StdPeriph_Templates.rar : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzmb&d=%2Fa%2F0X0000000bQ4%2FSwL3sFAhNls9gwG_9U7kEqm.1GjndcSdgpqEEUx7DX4&asPdf=false
Posted on July 25, 2012 at 17:51

One uses a SET register, the other a CLEAR register, which operate bitwise on the actual register.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 25, 2012 at 19:28

void TIM2_IRQHanler (void)
{
TIM_ClearFlag(TIM2, TIM_FLAG_Update);
GPIO_WriteBit(GPIOD, GPIO_Pin_15, Bit_SET);
delayxs(200000);
GPIO_WriteBit(GPIOD, GPIO_Pin_15, Bit_RESET);
delayxs(200000);
}

This needs to be TIM2_ Handler() for the name to match the one in the vector table. The other code doesn't look unreasonable, but I've not used encoder mode, or checked the TIM2 pins.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 25, 2012 at 21:11

I saw it, thank you clive1. Not hanler I had to write handler :S counter is counting correctly but I wrote int routine wrongly. I started to do the same thing which is wrong writing I'm sorry to loaf something away to you. I'm going to try it afternoon of tomorrow now I'm studying to my tomorrow morning's exam. Thanks to you again clive1.

Posted on August 01, 2012 at 14:24

It's working well. Thank you clive1

Posted on August 10, 2012 at 15:38

I'm trying to measure encoders speed (x2-x1)/T or X/(t2-t1) but Timer 6 is not counting true. Psc = 9999, Arr = 83, RCR = 0 , My event rate(period) is ;

    EP = (84MHz)/[(10000)*(84)*(1)] = 100 Hz

I want to read encoder's pulses per by 10ms but it's always interrupting at every (1,4 MHz) 0,7us. I wrote to PSC=65535, ARR=839, RCR=0 it is still same....

(I found it thank you for everyone :) )
Andrew Neil
Evangelist III
Posted on October 14, 2015 at 10:46

clive1's links from July 2012 now seem to be broken; try these:

AN3988 Application note, ''Clock configuration tool for STM32F40xx/41xx/427x/437x microcontrollers''

http://www.st.com/web/en/resource/technical/document/application_note/DM00039457.pdf

STSW-STM32091 ''Clock configuration tool for STM32F40x/41x microcontrollers''(AN3988)

http://www.st.com/web/en/catalog/tools/PF257927

http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/utility/stsw-stm32091.zip

But note that this is all now deprecated by ST - superseded by: 

http://www.st.com/web/en/catalog/tools/PF259242

STM32Cube initialization code generator (UM1718)