Mohammadali Estakhr 30077052 Embedded System: Abstract
Mohammadali Estakhr 30077052 Embedded System: Abstract
Mohammadali Estakhr 30077052 Embedded System: Abstract
30077052
Embedded System
Abstract:
-This RTC project uses RTOS to construct a digital alarm clock. It will entail utilizing E2 studio
to create the synergy C project "S7G2_ALARMCLOCK." The chosen combinations are listed
below. These are the J-Link ARM Debugger, the GCC ARM Embedded Toolchain, the
Toolchain Version 4.9.3.20150529, the SSP Version 1.6.0, and the Board support package for
the chosen synergy family (BSP).
Super loop architecture and RTOS (Real-Time-Operating System) served as the foundation for
this project. The SK-S7G2 starting kit was needed for the application in order to read the
digital alarm clock's program code.
The HAL/Common stack must be used by the configuration. Priority 4 is used for the Period
Interrupt priority and the Alarm Interrupt priority.
This was displayed in "hal_entry.c." The RTC HAL on r_rtc stack from the HAL/Common Stacks
Drivers Timers was then added after choosing HAL/Common in the threads tab. After then,
the project material was produced.
In hal_entry.c, include an entry method that invokes rtc_initiate(). This was then assembled
again without any faults or warnings. The SK-S7G2 board is linked to the host at the other end
of the USB cord.
first, the BSP project template was chosen, and then a new Renesas Synergy Project for the SK-
S7G2 board called RTC_HAL was created.
After choosing the configuration file from the project, the RTC HAL on the r_rtc stack from the
HAL/Common Stacks Drivers Timers was chosen, followed by the Threads tab, the
Hal/Common tab, and the Threads tab.
After choosing the interrupt priority, click the Generate ProjectContent button to start the
project's generation. After that, the program code was introduced from the entry function
hal_entry.c, which calls rtc_initiate(), and the file rtc_hal_mg.c/.h.
The flow chart's design, which clearly displayed the program's operation flow, served as the
basis for writing this code.
Creating buttons on screen :
Using the GUIX interface, button B2 was created, and its settings were set to comply with the
necessary requirements.
The setup was then debugged into the S7G2 Board once the outputwas created. In accordance,
a picture display is attached.
Additionally, the alarm clock thread entry was made and set up to operate in line with the
project model and design's design specifications.
Enclosed with the C code for the thread entry for each of the events is the program
configuration.The state diagram is displayed. displaying the state machine's operational
sequence. It is the digital alarm clock in this instance.
The user-defined data, which was pre-configured in the project template, was utilized for the
time keeping variable for each RTC and alarm clock. According to the flow chart below,
button 2 will update the appropriate vanable of the time if any of the clocks is in a time
adjust condition.
Alarm ring state should be displayed by switching LEDs, as there are no available audio
outputs. The toggling function was implemented in this design in accordance with the
provided flow diagram.
Explainations about Real Time Clock :
We ought to be able to turn on or off the alarm in accordance with the necessity. The alarm
set feature has been implemented for that reason.
This function's objective is to visually display the alarm set states by turning on LED 2 and
verifying that the alarm is activated by utilizing the alarm active flag.
If the alarm is on and no button is pressed, it should turn off automatically. In order to do
that, we have included a second hardware timer, designated timer 1, with a one-minute
duration within the RTC Thread in this architecture.
This timer was set up as a one-shot timer, meaning that it must be manually restarted each
time the timer overflows.
Conclusion:
In conclusion, creating a diagram of state transitions to control various modes of operation,
such as regular display and alarm activation, is a necessary step in constructing a digital alarm
clock using the Renesas S7G2-SK development board.
While the alarm functionality only permits the setting and clearing of alarms while the display
is in its usual state, the clock feature uses LEDs to show the current time. LEDs are used to
show if the alarm is set and in what condition.
Two buttons allow the user to interact: one for mode selection and the other for stopping
the alarm. Furthermore, if the alarm is not manually turned off after one minute, automatic
alarm stopping takes place. Making sure the digital alarm clock implementation is reliable
and functioning requires careful testing, optimization, documentation, and deployment.
SG72_alarmclock setting screenshots :
SG72_alarmclock Code:
#include "RTC_thread.h"
#include "u_rtc_clk.h"
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_00,IOPORT_LEVEL_HIGH); // turning of
green LED
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_01,IOPORT_LEVEL_HIGH); // turning of
Red LED
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_02,IOPORT_LEVEL_HIGH); // turning of
Amber LED
state = rtc_clk;
while (1)
if(Alarm_flag == 1)
{
if(toggling)
{
toggling=0;
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_00,IOPORT_LEVEL_LOW); //
turning on LED 1
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_01,IOPORT_LEVEL_HIGH); //
turning on LED 2
}
else
{
toggling=1;
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_00,IOPORT_LEVEL_HIGH); //
turning off LED 1
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_01,IOPORT_LEVEL_LOW); //
turning off LED 2
}
R_BSP_SoftwareDelay(500,BSP_DELAY_UNITS_MILLISECONDS); // creating delay
of 5 seconds
if(flag_B1==0 |flag_B2==0)
{
Alarm_flag = 0;
}
}
{
Alarm_flag = 1; //notice alarm flag
g_timer1.p_api->start(g_timer1.p_ctrl); // start
the hardware timer
if(flag_B1 == 1)
{
flag_B1 = 0; // reseting B1 flag
state = rtc_clk_setH; // changing next state
}
if (flag_B2 == 1)
{
flag_B2 = 0; // reseting flag
state = alarm_clk;
}
break;
case rtc_clk_setH:
if(flag_B1 == 1)
{
flag_B1 = 0; //resetting flag B1
state = rtc_clk_setM; // changing state
}
if(flag_B2 == 1)
{
if (u_rtc_clk.hour>=23)
{
u_rtc_clk.hour = 0;
flag_B2 = 0; // reseting flag
}
else
{
u_rtc_clk.hour = u_rtc_clk.hour +1; // incrementing of hour
flag_B2 = 0;
}
}
break;
case rtc_clk_setM:
if(flag_B1 == 1)
{
flag_B1 = 0; // resetting flag B1
state = rtc_clk_setS; // changing state
}
if(flag_B2 == 1)
{
if (u_rtc_clk.min>=59)
{
u_rtc_clk.min = 0;
flag_B2 = 0; // reseting flag
}
else
{
u_rtc_clk.min = u_rtc_clk.min +1; // incrementing of hour
flag_B2 = 0; // resetting flag B1
}
}
break;
case rtc_clk_setS:
if(flag_B1 == 1)
{
flag_B1 = 0; // resetting flag B1
state = rtc_clk; // changing state
}
if(flag_B2 == 1)
{
if (u_rtc_clk.sec>=59)
{
u_rtc_clk.sec = 0;
flag_B2 = 0; // reseting flag
}
else
{
u_rtc_clk.sec = u_rtc_clk.sec +1; // incrementing of seconds
flag_B2 = 0;
}
}
break;
case alarm_clk:
if(flag_B2 == 1)
{
flag_B2=0; // resetting flag B2
state= rtc_clk;
}
if (flag_B1 == 1)
{
flag_B1 =0; // resetting flag B1
state = alarm_clk_setH;
}
break;
case alarm_clk_setH:
if(flag_B2 == 1)
{
state= alarm_clk_setM ;
flag_B1 = 0; // resetting flag B1
}
if (flag_B2 == 1)
{
if(u_Alarm_clk.hour >= 23)
{
u_Alarm_clk.hour = u_Alarm_clk.hour+1 ; // increment alarm
clock hour
flag_B2 = 0; // resetting flag B2
}
else
{
u_Alarm_clk.hour = 0;
flag_B2=0; // resetting flag B2
}
break;
case alarm_clk_setM:
if(flag_B1 == 1)
{
state= alarm_clk_setS ;
flag_B1 = 0; // resetting flag B1
}
if (flag_B2 == 1)
{
if(u_Alarm_clk.min>=59)
{
u_Alarm_clk.min = 0; ;
flag_B2 = 0; // resetting flag B2
}
else
{
u_Alarm_clk.min = u_Alarm_clk.min+1; // increment alarm clock
minutes
flag_B2=0; // resetting flag B2
}
}
break;
case alarm_clk_setS:
if(flag_B1 == 1)
{
state= alarm_clk ;
flag_B1 = 0; // resetting flag B1
}
if (flag_B2 == 1)
{
if(u_Alarm_clk.sec>=59)
{
u_Alarm_clk.sec = u_Alarm_clk.sec +1 ;
flag_B2 = 0; // resetting flag B2
}
else
{
u_Alarm_clk.sec = 0;
flag_B2=0;
}
}
break;
default:
break;
if (u_rtc_clk.sec>=59)
{
u_rtc_clk.sec = 0;
if (u_rtc_clk.min>=59)
{
u_rtc_clk.min = 0;
if (u_rtc_clk.hour>=23)
{
u_rtc_clk.hour = 0;
}
else
{
u_rtc_clk.hour = u_rtc_clk.hour+1 ; // increment hours
}
}
else
{
u_rtc_clk.min = u_rtc_clk.min+1; // increment minutes
}
}
else
{
u_rtc_clk.sec = u_rtc_clk.sec+1 ; // increment seconds
}
}