cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S103F3 tsspop20 Alternate Function Remapping AFR0

dhemaius
Associate II
Posted on September 11, 2009 at 10:24

STM8S103F3 tsspop20 Alternate Function Remapping AFR0

6 REPLIES 6
dhemaius
Associate II
Posted on May 17, 2011 at 15:04

Hi,

I'm having trouble trying to remap TIM1_CH1 and TIM1_CH2 using AFR0 option bit. In the memory window in debug mode, Option Byte @0x4803 holds de right value, but I can't get the output to change state on the proper pins.

I have TIM1_CH3 and TIM1_CH4 working just fine with the exact same configuration as _CH1 and _CH2. So I know this is not a configuration issue.

Is there any specific algo to follow at power-up to make sure alternate function remapping works or is there any issue with that particular remapping on that device?

Thanks,

Francis Savaria

brazov2
Associate II
Posted on May 17, 2011 at 15:04

Hi,

Did you read value @0x4804? It'd equal to FEh, if not try to write 01h @0x4803 and FEh @0x4804 and then reset the device.

coluber

dhemaius
Associate II
Posted on May 17, 2011 at 15:04

Alright, here is some information I forgot to tell:

- I work with Raisonnace Ride7 environment;

- Option bytes OPT2/NOPT2 values were validated through Memory View debug window and through Option debug window;

- Current desired remapping is 0x05/0xFA (AFR0 & AFR2), but TIM1 OC1 and OC2 still won't work, while OC3 and OC4 are alright;

- I tried AFR0 both alone and with AFR2.

I have designed an alternative for what I need to accomplish, but the day I'm going to need those outputs working is not far. Did I hit a bug or am I just clueless? :-]

Merci d'avance,

Francis Savaria

brazov2
Associate II
Posted on May 17, 2011 at 15:04

Hi,

I've tried your configuration, previously setting both AFR0 and AFR2 and I can see correctly toggle TIM1_CH1(PC6) and TIM1_CH2(PC7).

coluber

dhemaius
Associate II
Posted on May 17, 2011 at 15:04

So I must be clueless... :-[

[...]

// set alternate function remapping

FLASH_ProgramOptionByte(0x4803, (AFR0|AFR2));

[...]

// init outputs

GPIO_Init(GPIOC, (GPIO_PIN_7 | GPIO_PIN_6 | GPIO_PIN_4 | GPIO_PIN_3), GPIO_MODE_OUT_PP_LOW_SLOW);

[...]

// enable OC outputs

TIM1->CCER1 |= (u8)(TIM1_CCER1_CC2E | TIM1_CCER1_CC1E);

TIM1->CCER2 |= (u8)(TIM1_CCER2_CC4E | TIM1_CCER2_CC3E);

[...]

All values in the control and config registers are what I want them to be (all 4 channels with the same config) and OC1 (TIM1_IER_CC1IE) interrupt is even working! PC7 and PC6 are working fine as GPIOs.

So... what else do you think I should look for?

brazov2
Associate II
Posted on May 17, 2011 at 15:04

Hi,

In my example I set CCMR1,CCMR2,CCMR3,CCMR4 to 60h (PWM mode1), also MOE is set, and no need to initialize PORTC. I hope this can help you.

coluber