cancel
Showing results for 
Search instead for 
Did you mean: 

How to control buzzer alarm and device power press key by RTC in LSI mode

Md Mubdiul Hasan
Associate III
Posted on September 21, 2016 at 02:43

Hi dear all,

I am using STM32F070RB-T6  to control a buzzer for 10 sec beeps and a power ON press key in my circuit.

How to use RTC, DMA here in LSI mode?

Kindly share code and disscuss it.

Thanks in advance.

2 REPLIES 2
Nesrine M_O
Lead II
Posted on September 21, 2016 at 10:54

Hi hasan.md_mubdiul,

I suggest you to have a look to the RTC example under the STM32F0 cube firmware package:

STM32Cube_FW_F0_V1.6.0\Projects\STM32F070RB-Nucleo\Examples\RTC\RTC_Alarm

This example guides you through the different configuration steps by mean of HAL API to ensure Alarm configuration and generation using the RTC peripheral.

-Syrine-

Md Mubdiul Hasan
Associate III
Posted on September 22, 2016 at 10:05

Dear Sir,

I went through this project file.

My application is different(may be for my ignorance).

At the beggining I am trying to press a power button, at the same 2 pin will be turn on alternatively, then buzzer and  7segment will reset.

I need to understand state machine, timer implementation, periferal clock distribution and other things.

Take a look this code,

  void EXTI0_IRQHandler(void)

       {

         if(EXTI_GetITStatus(USER_BUTTON_EXTI_LINE) != RESET)

         else

        (db_count = 16)

               EXTI->PR = 0x00000200;

            else

              EXTI_ClearITPendingBit(EXTI_Line9

     

     

     

      void main()

    

      {

  

         do

           {

             if(PORTC.PC5 == 0)   //If the KEY_SW1 switch is pressed

             {

                Delay_ms(100);    //Switch Debounce

                if(PORTC.PC5 == 0)//If the switch is still pressed

                {

                

                

                       GPIO_ToggleBits ( GPIOB,TRIAC_CON1_Pin);

                       PORTD.PD2 = 1; //LED7 ON

                       LED7Toggle = 4000;  //4 seconds

                       Delay_ms(1000); //1 Second Delay

                       PORTD.PD2 = 0; //LED OFF

                 }

           } else {    

                 PORTC.PC5 == 0; //If the KEY_SW1 switch is pressed

                

                  /* set led on */

                GPIO_SetBits( TRIAC_CON2_Pin);

                PORTD.PD2 = 1; //LED7 ON

                LED7Toggle = 4000;  //4 seconds

                Delay_ms(1000); //1 Second Delay

                PORTD.PD2 = 0; //LED OFF

                                }

                 

                        }

                     }while(1);

                    }