cancel
Showing results for 
Search instead for 
Did you mean: 

stm8s active halt mode PA1 port pin issue

mehta.vishal
Associate II
Posted on December 28, 2012 at 12:18

hello,

following is the short details about the objective of the program..and their after the problem what i am facing...

I am using stm8s005c6t6 controller and  we are using capacitive based power supply (lm7805) regulator is connected at the unregulated dc to get the 5v supply. I have connected PORTA pin 1 to drive the relay. Since relay takes 30mA of current....so when ever relay has to be switched i send the controller to active halt mode with master frequecy set to LSI 128khz and AWU with delay of 0.5S...and in the interrupt routine of AWU i will first switch off the relay and then switch the frequency to again HSI-16mhz.

Problem:- when i set PA1 and goes into active halt mode, PA1 automatically goes to zero...and after AWU wakeup interrupt...PA1 come back to high state...if i use any other port instead of PA1 it works fine...but the issue is only with PA1.....i am not able to understand the problem....so finally i am using wfi() instruction instead of active halt...and then it works...

can any one suggest me the cause of the problem or any other kind of solution...

thanks in advance....

#stm8s-active-halt-mode
6 REPLIES 6
fggnrc2
Associate II
Posted on December 28, 2012 at 15:13

Hello metha.

PA1 may be used for OSCIN too.

I therefore suppose that STM8S005 microcontroller hardware takes full control of this pin during an active halt or when the clock source changes.

I suggest you to check all configuration options and read carefully any documentation about active halt and clock sources.

Regards,

EtaPhi

mehta.vishal
Associate II
Posted on December 29, 2012 at 06:24

Hello EtaPhi,

first of all thanks for your reply.....actual i have read carefully about CLK, AWU, option bytes..etc..but i am not able to find the reason....

Secondly, If i execute the program in debug mode (using discovery kit)...it works as per the logic...but once i exit from the debug mode(SWIM based)...it again starts..to behave in same manner....

If you are able to find any reason...do tell me....currently i am using wfi(), instead halt...

fggnrc2
Associate II
Posted on December 29, 2012 at 15:21

Metha,

in STM8S103K3, STM8S103F3 and STM8S103F2 datasheet there is this little notice

When the MCU is in Halt/Active-halt mode, PA1 is automatically configured in input weak pull-up and cannot be used for waking-up the device. In this mode, the output state of PA1 is not driven. It is recommended to use PA1 only in input mode if Halt/Active-halt is used in the application�?.

This notice is missing in STM8S005C6T6 datasheet, but it seems that it also applies to your case.

When a microcontroller is in debug mode (SWIM), it behaves almost as it behaves in run mode, but sometimes something strange happens. For istance, if you read my post “STM8 core bug�?, you'll see a situation when a single step execution yelds a wrong result.

It's therefore not surprising that your code works in debug mode because in this mode an HALT instruction can't stop microcontroller hardware to keep SWIM session active.

EtaPhi

mehta.vishal
Associate II
Posted on December 29, 2012 at 16:17

Hello EtaPhi,

Thanks for the reply.....i will read the datasheet of  stm8s103k...and also check it.....and reply you tomorrow about the testing result....once again...thanks...

second, i need your comment and suggestion....

Actual, the final product is about the 3 phase motor protection relay (based on 3 currents of the ac motor and to protect it + timer to control the switching of motor for domestic use)...

for these i have selected the above controller..(i.e stm8s005c6t6)....after initial production i will upgrade it to stm8l controller..later.

Currently i am testing the final firmware...so, can you suggest if it is ok to use stm8s controller.

for the above application...or any kind of problem may arise in the later stage ...(core bug etc)

your comment will be useful for me to build the confidence....

thanks and regards,

vishal mehta

fggnrc2
Associate II
Posted on December 30, 2012 at 07:03

Hello Metha.

I can only tell you my experience with STM8 microcontrollers which is far from exhaustive because I never used STM8L micros in my projects (until now).

I like the STM8 core because of its 8/16 bit instruction set which makes it easy to add or multiply or divide two 16 bit (unsigned) integers. It's also shared between all STM8 micros and it simply … works.

I feel that STM8L micros are more fragile and trickier to use because its software must emulate some device functionality (e.g. ADC) which its designers removed to reduce current consumpion. On the contrary, they have got a DMA unit which offloads the STM8 core, but adds complexity.

So, if your application works with a STM8S005C6T6, I see no real reason in upgrading to a STM8L micro because if your application uses a capacitive power supply, it's always connected to the power grid and therefore it doesn't need to drain as few power as possible from a battery.

Moreover, STM8S micros supply voltage can be as high as 5.5 V, while the maximum supply voltage of STM8L micros is 3.6 V.

When there is a three phase motor, there are usually voltage spikes and noise which can pass through your capacitive supply.

Even if your application is designed for a 3V3 power supply, I think that it's better to design a wider operation margin to withstand the unexpected...

This is my opinion upon which you may agree or not.

But it agrees with the common wisdom which says … if it isn't broken, don't fix it!

mehta.vishal
Associate II
Posted on December 30, 2012 at 11:49

Hello EtaPhi,

thanks for the reply.....

after your comment it is easy for me to take the decision....

secondly, i am happy and appreciate your knowledge...and attitude to share it with others....(thanks)...

if i face any other problem...i will come back to you...

thanks & regards,

vishal mehta,

India.