{"id":8793,"date":"2022-03-31T04:27:43","date_gmt":"2022-03-31T04:27:43","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=8793"},"modified":"2023-08-23T12:39:56","modified_gmt":"2023-08-23T07:09:56","slug":"fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/","title":{"rendered":"FSM Lecture 87| Exercise-008:Implementation part 6"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"text-align: center; font-size: 30px; border-width: 0px; line-height: 50px;\"><strong><span style=\"color: #000080;\">Exercise-008:Implementation part 6<\/span><\/strong><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -25px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<p>&nbsp;<\/p>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In this article, to use the QP-Nanos Active Object Framework, you have to implement a couple of steps. Let&#8217;s discuss that now.<\/span><\/p>\n<figure id=\"attachment_8796\" aria-describedby=\"caption-attachment-8796\" style=\"width: 1082px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-8796 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-1-44.png\" alt=\"Figure 1. QF(Active Object Framework) QP-Nanos Active Object Framework\" width=\"1082\" height=\"479\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44.png 1082w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44-300x133.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44-768x340.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44-1024x453.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44-600x266.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44-120x53.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44-500x221.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44-200x89.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44-400x177.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-1-44-800x354.png 800w\" sizes=\"(max-width: 1082px) 100vw, 1082px\" \/><figcaption id=\"caption-attachment-8796\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. QF(Active Object Framework)<\/span><\/figcaption><\/figure>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">First, you have to create the event queues for the active objects that you have used in your application. In our application, we have used two active objects. We have to create two event queues. It is nothing but just a static array of QEvt structure.<\/span><\/li>\n<\/ul>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">After that, you have to create and initialize the Active object control block. It is nothing but there is a structure called QActiveCB. So, you have to create an array instance of this structure, and you have to initialize that.&nbsp;<\/span><\/li>\n<\/ul>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">After that, you have to call QF_init, and you have to mention the number of active objects used by your application. And this is to initialize the Active object framework of QP-nano. It accesses all the Active objects what you have mentioned in the control block, and it initializes that.&nbsp;<\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"margin-left: 7px; padding: 0em 0em 0em 1.9em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This also calls the init function of the underlying kernel. So, the underlying kernel in our case is QV, which is the cooperative vanilla kernel.<\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">After that, you have to call QF_run. This also calls the scheduler of the kernel, and it never returns.&nbsp;<\/span><\/li>\n<\/ul>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li><span style=\"font-weight: 400; color: #000000;\">And after that, if you want the framework to generate timeout events, a timeout could be a one-shot or periodic timeout. You have to use this function QF_tickXISR. This function should be called from your application&#8217;s tick ISR. That means your application now should provide one a periodic tick ISR, which is already there in our application. So, we have already used timer1 peripheral to generate a periodic interrupt for every 100 milliseconds. We will slightly modify that.<\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"padding-left: 30px; margin-left: 7px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And we&#8217;ll use that as our tick ISR because every RTOS or kernel should use a background tick ISR. And from that background tick ISR, you have to call this function. So, this gives the framework a chance to update all its time-related events.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s implement all these steps. Let&#8217;s first start with step 1, Create event queues.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now, let&#8217;s get back to the code main.cpp. We will create two arrays of QEvt type. We will create two arrays.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, the first array is ClockAlarmQueue and ButtonQueues of type a QEvt, and we will give space for 5 events. These are statically defined Event queues for our Active objects.&nbsp;<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #ff99cc;\">static<\/span> QEvt ClockAlarmQueue[5];\r\n<span style=\"color: #ff99cc;\">static<\/span> QEvt ButtonQueue[5];<\/pre>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The next step is to create and initialize an Active object control block. Now, let&#8217;s create a variable of QActiveCB. So, if you want to read about QActiveCB structures, check here in &#8216;qfn.h&#8217;, as shown in Figure 2.<\/span><\/p>\n<figure id=\"attachment_8798\" aria-describedby=\"caption-attachment-8798\" style=\"width: 1665px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-8798 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-3-35.png\" alt=\"QP-Nanos Active Object Framework\" width=\"1665\" height=\"1023\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35.png 1665w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-300x184.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-768x472.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-1024x629.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-600x369.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-120x74.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-500x307.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-200x123.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-400x246.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-800x492.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-3-35-1200x737.png 1200w\" sizes=\"(max-width: 1665px) 100vw, 1665px\" \/><figcaption id=\"caption-attachment-8798\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. qfn.h file<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">QActiveCB represents the read-only information that the QF-nano needs to manage the active object. The QActiveCB objects are grouped in the array QF_active[].<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Basically, it has three fields. Pointer to your active object, a pointer to the event queue of the active object, and here you must mention the length of the Event queue of your active object.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, you have to create a QF_active array now. Let&#8217;s do that.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\">QActiveCB <span style=\"color: #ff99cc;\">const<\/span> QF_active[] = {\r\n  { (QActive*) 0, (QEvt*) 0, 0},\r\n  { (QActive*) AO_ClockAlarm,(QEvt*)ClockAlarmQueue,Q_DIM(ClockAlarmQueue)},\r\n  { (QActive*) AO_Button,(QEvt*)ButtonQueue,Q_DIM(ButtonQueue)}\r\n};<\/pre>\n<p class=\"\" style=\"text-align: center;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">QActiveCB<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b>QActiveCB const QF_active[]<\/b><span style=\"font-weight: 400;\"> and let&#8217;s initialize this with all the active objects. The first entry should be a Null entry, and you can do like this Qactive*. You can just typecast to QActive*. And the second member element is a pointer to the event queue; you can write like this QEvt*. And the third one is the length, which is 0.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, the second entry you start with your first active object, that is AO_ClockAlarm; address of the Event queue, that is ClockAlarmQueue; And length. The length of this is ClockAlarmQueue. For this, you can use this macro Q_DIM; you mention the array name like this. You can do like for AO_Button.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Q_DIM macro helps you to calculate the number of elements in the given array(Figure 4). QActiveCB code is shown above. We created the Active object control block.<\/span><\/p>\n<figure id=\"attachment_8801\" aria-describedby=\"caption-attachment-8801\" style=\"width: 1731px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-8801 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-5-32.png\" alt=\"QP-Nanos Active Object Framework\" width=\"1731\" height=\"787\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32.png 1731w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-300x136.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-768x349.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-1024x466.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-600x273.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-120x55.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-500x227.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-200x91.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-400x182.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-800x364.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-5-32-1200x546.png 1200w\" sizes=\"(max-width: 1731px) 100vw, 1731px\" \/><figcaption id=\"caption-attachment-8801\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Q_DIM macro<\/span><\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The third step is QF_init. This QF_init is there in qvn.c. The proper usage of this function is mentioned here (Figure 5). <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">You have to send a number of active objects your application uses, which can be calculated using Q_DIM macro over QF_active array variable. Let&#8217;s do that.&nbsp;<\/span><\/p>\n<figure id=\"attachment_8802\" aria-describedby=\"caption-attachment-8802\" style=\"width: 1731px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8802 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-6-33.png\" alt=\"QP-Nanos Active Object Framework\" width=\"1731\" height=\"907\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33.png 1731w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-300x157.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-768x402.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-1024x537.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-600x314.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-120x63.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-500x262.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-200x105.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-400x210.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-800x419.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-6-33-1200x629.png 1200w\" sizes=\"(max-width: 1731px) 100vw, 1731px\" \/><figcaption id=\"caption-attachment-8802\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. qvn.h, QF_init<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After the button_ctor, we can do that. QF_init, let&#8217;s use the Q_DIM of this QF_active, as shown below.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #ff99cc;\">void<\/span> setup() {\r\n<span style=\"color: #008000;\">  \/\/ put your setup code here, to run once:<\/span>\r\n  Serial.begin(9600);\r\n  display_init();\r\n  attach_button_interrupts();\r\n  Clock_Alarm_ctor();\r\n  Button_ctor();\r\n  QF_init(Q_DIM(QF_active));\r\n\r\n  Timer1_setup();\r\n}<\/pre>\n<p class=\"\" style=\"text-align: center;\"><span style=\"color: #000000;\">QF_init code<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And after that fourth step is QF_run.&nbsp; QF_run can be called from the loop function because you cannot call&nbsp; QF_run in the setup function. Because it never returns.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">QF_run, as you can see here, is there in qvn.c. This has one giant loop here, which is a scheduler, you see that in Figure 6. It executes the events for the active objects in a cooperative manner.&nbsp;<\/span><\/p>\n<figure id=\"attachment_8804\" aria-describedby=\"caption-attachment-8804\" style=\"width: 1679px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8804\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-8-29.png\" alt=\"Figure 8. qvn.c,QF_run\" width=\"1679\" height=\"1023\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29.png 1679w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-300x183.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-768x468.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-1024x624.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-600x366.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-120x73.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-500x305.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-200x122.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-400x244.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-800x487.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-8-29-1200x731.png 1200w\" sizes=\"(max-width: 1679px) 100vw, 1679px\" \/><figcaption id=\"caption-attachment-8804\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. qvn.c, QF_run<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">If there are no events to be processed, then it calls the Idle hook function. This Idle hook function must be implemented in your application.&nbsp;&nbsp;<\/span><\/p>\n<figure id=\"attachment_8805\" aria-describedby=\"caption-attachment-8805\" style=\"width: 1673px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8805\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-9-27.png\" alt=\"Figure 9. Idle hook function\" width=\"1673\" height=\"1023\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27.png 1673w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-300x183.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-768x470.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-1024x626.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-600x367.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-120x73.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-500x306.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-200x122.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-400x245.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-800x489.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-9-27-1200x734.png 1200w\" sizes=\"(max-width: 1673px) 100vw, 1673px\" \/><figcaption id=\"caption-attachment-8805\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Idle hook function<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">We will implement the QV_onIdle function in our main.c. So, you can here put the processor to sleep, that sleep-related function also given in the qfn_port.h. This is a port for the avr based microcontroller. You can see that(Figure 8), there is already a macro present QV_CPU_SLEEP. So, it enables the interrupt, and it just sleeps. We will call this function from there. Let&#8217;s go to the main.cpp, and we&#8217;ll call that function, as shown below.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #ff99cc;\">void<\/span> QV_onIdle(<span style=\"color: #ff99cc;\">void<\/span>){\r\n&nbsp; &nbsp;QV_CPU_SLEEP();\r\n}<\/pre>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_8807\" aria-describedby=\"caption-attachment-8807\" style=\"width: 1703px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8807\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-11-17.png\" alt=\"Figure 11. QV_CPU_SLEEP function\" width=\"1703\" height=\"1029\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17.png 1703w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-300x181.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-768x464.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-1024x619.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-600x363.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-120x73.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-500x302.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-200x121.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-400x242.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-800x483.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-11-17-1200x725.png 1200w\" sizes=\"(max-width: 1703px) 100vw, 1703px\" \/><figcaption id=\"caption-attachment-8807\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. QV_CPU_SLEEP function<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, the next step is to call the OF_tickXISR function from your application&#8217;s tick ISR. And we already have this Timer1_setup. What does it? It generates an interrupt for every 100 milliseconds. What we will do is we will modify this Timer1 interrupt code to generate an interrupt for every 1 millisecond. That will be our tick ISR. <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And from that tick ISR, we will call that function. That&#8217;s why we have to slightly modify this now to generate the timer interrupt for every 1 millisecond.<\/span><\/p>\n<figure id=\"attachment_8808\" aria-describedby=\"caption-attachment-8808\" style=\"width: 1653px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8808\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-12-14.png\" alt=\"Figure 12. Timer1_setup function\" width=\"1653\" height=\"1023\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14.png 1653w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-300x186.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-768x475.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-1024x634.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-600x371.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-120x74.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-500x309.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-200x124.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-400x248.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-800x495.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-12-14-1200x743.png 1200w\" sizes=\"(max-width: 1653px) 100vw, 1653px\" \/><figcaption id=\"caption-attachment-8808\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Timer1_setup function<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, for that, I&#8217;ll be using some macros. I&#8217;ll put that in main.h.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s go to the main.h, and I&#8217;m going to use some macros. So, these macros are very simple, as shown in Figure 10.<\/span><\/p>\n<figure id=\"attachment_8809\" aria-describedby=\"caption-attachment-8809\" style=\"width: 989px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8809\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-13-11.png\" alt=\"Figure 13. Macros \" width=\"989\" height=\"717\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-13-11.png 989w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-13-11-300x217.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-13-11-768x557.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-13-11-600x435.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-13-11-120x87.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-13-11-500x362.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-13-11-200x145.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-13-11-400x290.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-13-11-800x580.png 800w\" sizes=\"(max-width: 989px) 100vw, 989px\" \/><figcaption id=\"caption-attachment-8809\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 10. Macros<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">We can modify the config items. Currently, I have set the TCCR1B_PRESCALER to TCCR1B_PRESCALER1, which means no clock division. And CONFIG_TIMER1_PRESCALER to this value TIMER1_PRESCALER_1. So basically, this is nothing but 1.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">CONFIG_TICKS_PER_SECOND represents the rate of the tick interrupts. TICKS_PER_SECOND means 1000 ticks per second. That means 100Hz. For every 1 second, there will be 1000 timer interrupts. That means 1 timer interrupt will arrive for every 1 millisecond. So, that&#8217;s a rate.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And MS_PER_TICK is a macro, which calculates milliseconds per tick. You have to divide 1000 milliseconds by CONFIG_TICKS_PER_SECOND.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And then TIMER1_OC_MATCH_VALUE calculates the Timer1&#8217;s match value, the match value that you need to configure into the timer once output compare register to get the tick rate of this much (CONFIG_TICKS_PER_SECOND).<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">MS_TO_TICKS is a helper macro, which converts milliseconds to ticks.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">We will slightly modify our Timer1_setup code. Now I will change Timer1_setup to sys_tick_init. In the code, where is the timer1_setup, you change that to sys_tick_init. The modified code as shown below.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #ff99cc;\">static void<\/span> sys_tick_init(<span style=\"color: #ff99cc;\">void<\/span>){\r\n&nbsp; &nbsp;TCCR1A = TCCR1A_CTC_MODE;&nbsp; &nbsp; <span style=\"color: #008000;\">\/\/CTC mode<\/span> \r\n&nbsp; &nbsp;TCCR1B = (TCCR1B_CTC_MODE |TCCR1B_PRESCALER_1);&nbsp; &nbsp; <span style=\"color: #008000;\">\/\/prescaler=1,CTC mode<\/span>\r\n&nbsp; &nbsp;TIMSK1 |= B00000010;&nbsp; &nbsp;<span style=\"color: #008000;\"> \/\/Interrupt enable for OCR1A compare match<\/span>\r\n&nbsp; &nbsp;OCR1A = TIMER1_OC_MATCH_VALUE;&nbsp; &nbsp;<span style=\"color: #008000;\"> \/\/OC match value for CONFIG_TICKS_PER_SECOND time base generation<\/span>\r\n}<\/pre>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, you have to call this function QF_tickXISR() from the tick ISR.<\/span><\/p>\n<figure id=\"attachment_8811\" aria-describedby=\"caption-attachment-8811\" style=\"width: 1176px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8811 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-15-10.png\" alt=\"Implementation part 6\" width=\"1176\" height=\"398\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10.png 1176w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10-300x102.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10-768x260.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10-1024x347.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10-600x203.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10-120x41.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10-500x169.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10-200x68.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10-400x135.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-15-10-800x271.png 800w\" sizes=\"(max-width: 1176px) 100vw, 1176px\" \/><figcaption id=\"caption-attachment-8811\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 11. QF_tickXISR()<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s go to the model file. In the ClockAlarm_SM.cpp, we have the ISR. From here you should call. And you should send one argument to that function. <\/span><\/p>\n<figure id=\"attachment_8812\" aria-describedby=\"caption-attachment-8812\" style=\"width: 1169px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8812 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-16-8.png\" alt=\"Implementation part 6\" width=\"1169\" height=\"709\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8.png 1169w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8-300x182.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8-768x466.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8-1024x621.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8-600x364.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8-120x73.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8-500x303.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8-200x121.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8-400x243.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-16-8-800x485.png 800w\" sizes=\"(max-width: 1169px) 100vw, 1169px\" \/><figcaption id=\"caption-attachment-8812\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 12. ClockAlarm model file<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_8813\" aria-describedby=\"caption-attachment-8813\" style=\"width: 943px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8813 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-17-6.png\" alt=\"Implementation part 6\" width=\"943\" height=\"723\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-17-6.png 943w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-17-6-300x230.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-17-6-768x589.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-17-6-600x460.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-17-6-120x92.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-17-6-500x383.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-17-6-200x153.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-17-6-400x307.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-17-6-800x613.png 800w\" sizes=\"(max-width: 943px) 100vw, 943px\" \/><figcaption id=\"caption-attachment-8813\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 13. QF_tickXISR(), QActive_armX()<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Why do you need to call QF_tickXISR? <\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This gives the framework a chance to process all armed time events. The time events can be armed by using a QActive_armX and disarm function. You can arm for any timeout using the QActive_arm function.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">As this description says, this function must be called periodically from the time-tick ISR. And you have to mention one argument, which is system clock tick rate, and this value can be 0 to 3. Basically, this identifies the system tick rate. <\/span><span style=\"font-weight: 400;\">Each system tick rate post timeout events with different signals are as follows. If we have used tick rate 0 here, when you use this QActive_arm function, then with that function, you have to mention the associated tick rate value. If it is 0 for example, the framework sends a timeout event with this name after a timeout Q_TIMEOUT. If the tick rate value is 1, the framework sends you a timeout signal with a signal name Q_TIMEOUT1 like that. <\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">So, we will use 0 here in the model file, as shown in figure 12. <\/span><b>QFtickISR(0)<\/b><span style=\"font-weight: 400;\">.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Whenever you arm for a timeout using this QActive_arm function, for every invocation of the QFtickISR function, the framework checks whether there is really a timeout or not.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">If there is a timeout, then it sends an event with the signal name Q_TIMEOUT if tickRate is 0; otherwise, Q_TIMEOUT1 if the tickRate is 1, like that.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Whenever a button press is detected, either ISR1 runs or ISR2 runs. We have got 2 button ISRs. Inside the ISR, we will use a flag. If this flag is true, then Arm_timer for the BOUNCE_TIME. Basically, it&#8217;s a one-shot timer. So, we will arm and one-shot timer for the BOUNCE_TIME. And when that BOUNCE_TIME is over, a framework sends a timeout signal to the Event Queue of the button active object. When the button active object receives the Q_TIMEOUT signal, it comes to know that someone has pressed the button and the bounce time is over. It can safely read the button status or the button pad status.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">It reads the button status, it decodes that. So, it comes to know whether it needs to send a SET signal, OK signal, or ABRT signal, and that signal will be sent to the event queue of the Clock_Alarm AO.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Then, the button active object makes that flag = true. It will be a global flag shared between this button active object and the ISRs. So, you have to manage it in a thread-safe manner.<\/span><\/p>\n<figure id=\"attachment_8814\" aria-describedby=\"caption-attachment-8814\" style=\"width: 1069px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8814 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-18-5.png\" alt=\"Implementation part 6\" width=\"1069\" height=\"426\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5.png 1069w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5-300x120.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5-768x306.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5-1024x408.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5-600x239.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5-120x48.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5-500x199.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5-200x80.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5-400x159.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5-800x319.png 800w\" sizes=\"(max-width: 1069px) 100vw, 1069px\" \/><figcaption id=\"caption-attachment-8814\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 14. Button ISR()<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now, we will implement this logic. If the button is bouncing here in Button_ISR_1, then this flag is since it is already false; that&#8217;s why this function will not get called for the next time until the button active object makes it &#8216;true&#8217; again here. Now, we will implement this one.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s go back to the code. In the main.h, we will extern one variable. <strong>extern uint8_t flag_report_button_press<\/strong>, as shown in Figure 15.&nbsp;<\/span><\/p>\n<figure id=\"attachment_8815\" aria-describedby=\"caption-attachment-8815\" style=\"width: 1857px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8815 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-19-3.png\" alt=\"Implementation part 6 - QP-Nanos Active Object Framework\" width=\"1857\" height=\"829\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3.png 1857w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-300x134.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-768x343.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-1024x457.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-600x268.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-120x54.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-500x223.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-200x89.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-400x179.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-800x357.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-19-3-1200x536.png 1200w\" sizes=\"(max-width: 1857px) 100vw, 1857px\" \/><figcaption id=\"caption-attachment-8815\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 15. main.h file<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now, let&#8217;s go to the ISRs. In the main.cpp, we have the ISR. Let&#8217;s go to the SET ISR. Here, let&#8217;s first disable the interrupt. You can use &#8216;cli&#8217; instruction or use the macro provided by this framework, that is, QF_INT_DISABLE().&nbsp;&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And after that, if that flag is true, then we will make it false, and we will use the QActive_armX function.&nbsp; What is &#8216;me&#8217; here? See Figure 17; The timeout signal gets directly posted into the event queue of the active object pointed by this me pointer. That&#8217;s why this timeout event should be sent to the button active object. I will use AO_Button, the next event tickRate that is 0. And a number of ticks, we actually want a one-shot timeout for the bounce time. Bounce time is around 50 milliseconds. Let&#8217;s use the macro MS_TO_TICKS(50), which converts a number of milliseconds into ticks. After that, interval. Interval is not there because it&#8217;s a one-shot timer, so mention it as 0. After that, you can Enable the interrupt.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The same code you should place in OK_handler. The code is shown in Figure 16.&nbsp;<\/span><\/p>\n<figure id=\"attachment_8816\" aria-describedby=\"caption-attachment-8816\" style=\"width: 1535px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8816 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-20-2.png\" alt=\"Implementation part 6 - QP-Nanos Active Object Framework\" width=\"1535\" height=\"909\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2.png 1535w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-300x178.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-768x455.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-1024x606.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-600x355.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-120x71.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-500x296.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-200x118.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-400x237.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-800x474.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-20-2-1200x711.png 1200w\" sizes=\"(max-width: 1535px) 100vw, 1535px\" \/><figcaption id=\"caption-attachment-8816\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 16. Implementing ISRs<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_8817\" aria-describedby=\"caption-attachment-8817\" style=\"width: 1362px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8817 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-21-2.png\" alt=\"Implementation part 6 - QP-Nanos Active Object Framework\" width=\"1362\" height=\"669\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2.png 1362w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-300x147.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-768x377.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-1024x503.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-600x295.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-120x59.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-500x246.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-200x98.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-400x196.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-800x393.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-21-2-1200x589.png 1200w\" sizes=\"(max-width: 1362px) 100vw, 1362px\" \/><figcaption id=\"caption-attachment-8817\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 17. QActive_armX()<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After that, let&#8217;s go to the model and draw the state machine for the button active object. The state machine is very simple in this case. It just have to process, so there will be one state. I&#8217;ll call this state a Button.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And in the state machine of the button also gives the initial transition, and there is nothing to initialize actually, because it doesn&#8217;t have any attributes.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">It has only one transition, internal transition, whose name is Q_TIMEOUT.<\/span><\/p>\n<figure id=\"attachment_8818\" aria-describedby=\"caption-attachment-8818\" style=\"width: 1127px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8818 size-full\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-22.png\" alt=\"Implementation part 6\" width=\"1127\" height=\"599\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22.png 1127w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22-300x159.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22-768x408.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22-1024x544.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22-600x319.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22-120x64.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22-500x266.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22-200x106.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22-400x213.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-22-800x425.png 800w\" sizes=\"(max-width: 1127px) 100vw, 1127px\" \/><figcaption id=\"caption-attachment-8818\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 18. A state machine for the button active object<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_8819\" aria-describedby=\"caption-attachment-8819\" style=\"width: 1260px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8819 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-23.png\" alt=\"Implementation part 6 - QP-Nanos Active Object Framework\" width=\"1260\" height=\"566\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23.png 1260w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-300x135.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-768x345.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-1024x460.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-600x270.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-120x54.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-500x225.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-200x90.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-400x180.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-800x359.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-23-1200x539.png 1200w\" sizes=\"(max-width: 1260px) 100vw, 1260px\" \/><figcaption id=\"caption-attachment-8819\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 19. Q_TIMEOUT Transition code<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Whenever it receives a timeout, it should read the button status. The read the button pad status code shown in Figure 19.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So you have to post an event to the ClockAlarm active object. How to post an event? Let&#8217;s check.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s go back to the APIs, Reference, and here it is QACTIVE_POST(). This is how you post. You have to call this macro QACTIVE_POST.<\/span><\/p>\n<figure id=\"attachment_8820\" aria-describedby=\"caption-attachment-8820\" style=\"width: 1351px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8820 size-full\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/03\/Figure-24.png\" alt=\"Implementation part 6 - QP-Nanos Active Object Framework\" width=\"1351\" height=\"839\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24.png 1351w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-300x186.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-768x477.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-1024x636.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-600x373.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-320x200.png 320w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-120x75.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-500x311.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-200x124.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-400x248.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-800x497.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-24-1200x745.png 1200w\" sizes=\"(max-width: 1351px) 100vw, 1351px\" \/><figcaption id=\"caption-attachment-8820\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 20. QACTIVE_POST<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The &#8216;me&#8217; pointer, the destination is an active object; AO&nbsp;<\/span><span style=\"font-weight: 400;\">\u2192&nbsp;<\/span><span style=\"font-weight: 400; color: #000000;\">ClockAlarm, the signal is SET_SIG, and parameter. So, there is no parameter. Let me type 0. Let&#8217;s write this code for the OK signal and ABRT signal. And after that, make this flag = true again.&nbsp; And in the button_SM.cpp, you also include the &#8220;main.h&#8221; header file because it needs to access these macros and this variable.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In the following lecture, we will draw the state machine for the Alarm.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 20px; line-height: 30px;\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px;\"><span style=\"color: #000000;\">C<span style=\"font-weight: 400;\"><span style=\"color: #000000;\">lick here:<\/span>&nbsp;<\/span><\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/fastbitlab.com\/course1<\/span><\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Exercise-008:Implementation part 6 &nbsp; &nbsp; In this article, to use the QP-Nanos Active Object Framework, you have to implement a couple of steps. Let&#8217;s discuss that now. First, you have to create the event queues for the active objects that you have used in your application. In our application, we have used two active [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8814,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[17],"class_list":["post-8793","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-finite-state-machine","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>QP-Nanos Active Object Framework Implementation: Step-by-Step<\/title>\n<meta name=\"description\" content=\"Learn how to implement the QP-Nanos Active Object Framework with practical steps and examples. Create event queues, initialize active object\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"QP-Nanos Active Object Framework Implementation: Step-by-Step\" \/>\n<meta property=\"og:description\" content=\"Learn how to implement the QP-Nanos Active Object Framework with practical steps and examples. Create event queues, initialize active object\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-31T04:27:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-23T07:09:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1069\" \/>\n\t<meta property=\"og:image:height\" content=\"426\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"FSM Lecture 87| Exercise-008:Implementation part 6\",\"datePublished\":\"2022-03-31T04:27:43+00:00\",\"dateModified\":\"2023-08-23T07:09:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/\"},\"wordCount\":2504,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/Figure-18-5.png\",\"keywords\":[\"Finite state Machine(FSM)\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/\",\"name\":\"QP-Nanos Active Object Framework Implementation: Step-by-Step\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/Figure-18-5.png\",\"datePublished\":\"2022-03-31T04:27:43+00:00\",\"dateModified\":\"2023-08-23T07:09:56+00:00\",\"description\":\"Learn how to implement the QP-Nanos Active Object Framework with practical steps and examples. Create event queues, initialize active object\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/Figure-18-5.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/03\\\/Figure-18-5.png\",\"width\":1069,\"height\":426,\"caption\":\"Figure 18. Button ISR()\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FSM Lecture 87| Exercise-008:Implementation part 6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"QP-Nanos Active Object Framework Implementation: Step-by-Step","description":"Learn how to implement the QP-Nanos Active Object Framework with practical steps and examples. Create event queues, initialize active object","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/","og_locale":"en_US","og_type":"article","og_title":"QP-Nanos Active Object Framework Implementation: Step-by-Step","og_description":"Learn how to implement the QP-Nanos Active Object Framework with practical steps and examples. Create event queues, initialize active object","og_url":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-03-31T04:27:43+00:00","article_modified_time":"2023-08-23T07:09:56+00:00","og_image":[{"width":1069,"height":426,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"FSM Lecture 87| Exercise-008:Implementation part 6","datePublished":"2022-03-31T04:27:43+00:00","dateModified":"2023-08-23T07:09:56+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/"},"wordCount":2504,"commentCount":4,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5.png","keywords":["Finite state Machine(FSM)"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/","url":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/","name":"QP-Nanos Active Object Framework Implementation: Step-by-Step","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5.png","datePublished":"2022-03-31T04:27:43+00:00","dateModified":"2023-08-23T07:09:56+00:00","description":"Learn how to implement the QP-Nanos Active Object Framework with practical steps and examples. Create event queues, initialize active object","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/03\/Figure-18-5.png","width":1069,"height":426,"caption":"Figure 18. Button ISR()"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/fsm-lecture-87-exercise-qp-nanos-active-object-framework-implementation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"FSM Lecture 87| Exercise-008:Implementation part 6"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/8793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=8793"}],"version-history":[{"count":4,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/8793\/revisions"}],"predecessor-version":[{"id":15418,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/8793\/revisions\/15418"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/8814"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=8793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=8793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=8793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}