You are here

PSoC FreeRTOS Task Notification Value | Cypress Semiconductor

PSoC FreeRTOS Task Notification Value

[re-printed from https://iotexpert.com]

In the previous article I showed you how to use the FreeRTOS task notification mechanism to replace a binary semaphore.  In this article I will build PSoC FreeRTOS Task Notification Value firmware.  Every FreeRTOS task has one built-in “uint32_t” which you can use to pass information between the task that sends the notification and the task that receives the notification.  In this article, instead of using the task notification as a binary semaphore, I will use it as a Queue of depth 1 that can hold one 32-bit word.  I will also show you a lesson that I learned about the interrupt registers in the SCB UART.

PSoC FreeRTOS Task Notification Value

I start by copying the project 9-TaskNotify and calling it 10-TaskNotifyValue.  I thought that it would be interesting to pass the cause of the UART interrupt to the UART Task, so that it could be told to the user.  To do this I call “xTaskNotifyFromISR” instead of “vTaskGiveFromISR”.   This function lets me set the value of the FreeRTOS Task notification value, is case to the bit mask of the cause of the UART interrupt.  The function also lets you specific if you want to

  • eNoAction – don’t do anything (this is what the xTaskNotifyFromISR does)
  • eSetBits – or the current notification value with the value you send
  • eIncrement – increment the notification value by 1 (in which case it ignore the value you send)
  • eSetValueWithOverwrite – replace the current notification value with the value passed in this function
  • eSetValueWithoutOverwrite – if there is no pending write, then write the value from this function into the notification value

In the UART_Task I take the value and then clear all of the bit (aka set it to 0) when I exit.

CY_ISR(uartHandler)
{
    uint32_t intrBits = UART_GetRxInterruptSourceMasked();
    UART_SetRxInterruptMode(0); // Turn off the Rx interrupt
    BaseType_t xHigherPriorityTaskWoken;
    xTaskNotifyFromISR( uartTaskHandle,intrBits,eSetValueWithOverwrite,&xHigherPriorityTaskWoken);
    portYIELD_FROM_ISR( xHigherPriorityTaskWoken );

}

void UART_Task( void *arg)
{
    (void)arg;
    char c;
    UART_Start();
    UART_SetCustomInterruptHandler(uartHandler);
    while(1)
    {
        uint32_t intrBits;
              
        xTaskNotifyWait( 0x00,         /* Don't clear any bits on entry. */
                         ULONG_MAX,          /* Clear all bits on exit. */
                         &intrBits,
                         portMAX_DELAY );    /* Block indefinitely. */
      
        switch(intrBits)
        {
            case UART_INTR_RX_NOT_EMPTY:
                UART_UartPutString("Interrupt: FIFO Not Empty\n");
            break;
            
            case UART_INTR_RX_ERR:
                UART_UartPutString("Interrupt: Error\n");
            break;
                
            case UART_INTR_RX_FULL:
                UART_UartPutString("Interrupt: FIFO Full\n");
            break;
            
            default:
                UART_UartPutString("Interrupt: Unknown\n");
            break;
        }
        
        while(UART_SpiUartGetRxBufferSize())
        {
            c = UART_UartGetChar();
            UART_UartPutString("Char = ");
            UART_UartPutChar(c);
            UART_UartPutString("\n");
        }
        // re-enable the interrupt
        UART_ClearRxInterruptSource(UART_INTR_RX_NOT_EMPTY);
        UART_SetRxInterruptMode(UART_INTR_RX_NOT_EMPTY);
    }
}

New Learning

When I first wrote the program I had something “weird” happening.  Specifically it looked like I was getting the interrupt service routine called twice:

UART output from PSoC running FreeRTOS

 

I originally wrote the code like this:

CY_ISR(uartHandler)
{
    uint32_t intrBits = UART_GetRxInterruptSourceMasked();
    UART_SetRxInterruptMode(0); // Turn off the Rx interrupt
    UART_ClearRxInterruptSource(UART_INTR_RX_NOT_EMPTY);
    BaseType_t xHigherPriorityTaskWoken;
    xTaskNotifyFromISR( uartTaskHandle,intrBits,eSetValueWithOverwrite,&xHigherPriorityTaskWoken);
    portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}

But, what happens is:

  1. Turn off interrupts
  2. Clear the interrupt source (meaning turn off the flag in the SCB that says there is a character in the Rx Buffer)
  3. One or so UART clock cycles later the flag is reset (because there is still something in the UART Rx Buffer)
  4. Send the notification to the UART Task
  5. The UART Task wakes up and processes the UART Rx Buffer
  6. The UART Task turns back on the interrupts
  7. The interrupt is called because the RX_NOT_EMPTY flag is still set (it is set until it is clear)
  8. The interrupt handler clears the flag (which isn’t reset this time because there is nothing in the Rx buffer)
  9. The interrupt handler sends the notification
  10. The UART Task wakes up again… prints out the Flag..
  11. The UART Task tries to read out of the Rx Buffer… but there isn’t anything in it.

Each time I start thinking that I know what I am doing, I find something else to learn.  I suppose that is what makes this whole thing fun though.

Comments

jam.martinn1987_2774596's picture

The PSoC5 demo includes a schematic design with several peripherals to demonstrate their integration with the RTOS. The covered peripherals are the UART, LCD individual show and extraordinary sorts of timer implementations.

Web Link Source: Write My Coursework

zubairabbasi992_2995511's picture

A huge round of applause, keep it up. free tour stockholm

caroline.sanders1990_2774996's picture

hold my beer! last time i was making thesis paper writing service, I`ve automatized all work in 200 lines

so can u make it better?

Hannan Aslam's picture

I've been hunting down some tolerable stuff on the subject and haven't had any fortunes up until this point, You just got another greatest fan!.. voyance magie

zubairabbasi992_2995511's picture

Pleasant to peruse your article! I am anticipating sharing your enterprises and encounters. foot fetish pictures

sanasheikh339_2791971's picture

FreeRTOS is en emerging and growing company made is rapid progress since 2005. It has also proved to be a leading chip and transmitters designing company in the world. One of the most important perspectives of the FreeRTOS is its QA and QC standards, which are a promising thing for every purchaser. Assignment Help Online

zubairabbasi992_2995511's picture

It would be ideal if you share more like that. segwaystockholmairwheel.se

abigailbreslin02_2705736's picture

Exceptionally useful one for us and a debt of gratitude is in order for sharing this we will download it on our side and we will most likely get assistance from your lines as we Write My Essay require that kind of data since we are the specialist co-op and need to offer help to our clients on a dire premise.

zubairabbasi992_2995511's picture

I have been gaining a lot of usable and exemplifying stuff in your website. toponlinecasinosuk.co.uk

john watson's picture

In the past article, I demonstrated to you generally accepted methods to utilize the FreeRTOS errand notice instrument to supplant a paired semaphore in the primary Tools menu and select the part forms you require. Here is a photo demonstrating ResearchPaperTown.com to download a variant of the Component.

zubairabbasi992_2995511's picture

Really decent post. I just unearthed your weblog and needed to say that I have truly delighted in searching your blog entries. After all I'll be subscribing to your food and I trust you compose again soon! Men's leather bracelets

nidaamber55_2789381's picture

FreeRTOS is the transmitters designing company established in 2005.It's the best for quality assurance and quality control.I am a researcher and provide Online Assignment Help Dubai, so I will further research on it because I cant understand the programming code you have shared with us.

alexpaul863_2753481's picture

Thank you so much for sharing this with us. I have heard about this from some of the forums and since then I have been searching for the codes and the attributes. I am so thankful to you for providing that.
private tours of washington reviews

zubairabbasi992_2995511's picture

I truly welcome the sort of themes you post here. A debt of gratitude is in order for sharing us an extraordinary data that is really useful. Great day! holm law group san diego

zubairabbasi992_2995511's picture

You have finished a surprising job with you website. 50Connect

zubairabbasi992_2995511's picture

I might want to thank you for the endeavors you have made in composing this article. I am trusting the same best work from you later on also.. Judi Togel

zubairabbasi992_2995511's picture

I went over this website and I believe you have a lot of wonderful information, saved to my bookmarks free vr porn

zubairabbasi992_2995511's picture

Decent to peruse your article! I am anticipating sharing your enterprises and encounters. dubai second hand cars for sale

zubairabbasi992_2995511's picture

It's fitting time to make a few arrangements for the future and the time has come to be glad. I have perused this post and on the off chance that I would I be able to wish to recommend you few fascinating things or exhortation. Maybe you could compose next articles alluding to this article. I yearning to peruse considerably more things about it! Show Box

zubairabbasi992_2995511's picture

Yes i am completely concurred with this article and i simply need say this article is extremely decent and exceptionally enlightening article.I will make a point to be perusing your blog more. You made a decent point yet I can't resist the urge to ponder, shouldn't something be said about the other side? !!!!!!THANKS!!!!!! internet marketing marketing1on1 services pricing

zubairabbasi992_2995511's picture

Good composed article. It will be strong to any individual who uses it, including me. Continue doing what you are doing – can'r hold up to peruse more posts. Goose down pillow

Hannan Aslam's picture

i am surprisingly here. I discovered this board and I in discovering It really accommodating and it helped me out a great deal. I would like to present something back and help other people, for example, you helped me. slither.io games

mondevoyance_3031296's picture

It’s an excellent post. Thanks for sharing such a fruitful post. You have defined it very simply for so I understand what you say. Voyance audiotel pas cher.

zubairabbasi992_2995511's picture

This is an incredible rousing article.I am essentially satisfied with your great work.You put truly exceptionally accommodating data. Keep it up. Continue blogging. Hoping to perusing your next post. Plus500 review

zubairabbasi992_2995511's picture

Pleasant to be going to your online journal once more, it has been months for me. Well this article i've been sat tight for so long. I require this article to finish my task in the school, and it has same subject with your article. Much obliged, incredible offer. where can you buy forskolin

zubairabbasi992_2995511's picture

A debt of gratitude is in order for the decent blog. It was extremely helpful for me. I'm cheerful I discovered this site. Much obliged to you for offering to us,I too dependably discover some new information from your post. Brian Holm Attorney San Diego

twvhbsrf_3062116's picture

Selecting a Bilge Pump | West Marine

Aug 10, 2016 - They work the best when the bilge has a small sump where water collects. Centrifugal pumps use whirling vanes to draw fluid into the center of the pump and then push it outward from the center through an outlet port. They have a built-in strainer in their base that can be removed quickly for cleaning, which ...
Amazon Best Sellers: Best Boat Bilge Pumps - Amazon.com

Shoreline Marine Pump Lower Unit Fill. 4.5 out of 5 stars 430. Seaflo Automatic Submersible Boat Bilge… Seattle Sports Paddlers Bilge Pump. Attwood Tsunami Aerator Pump. Shoreline Marine Bilge Pump. Amarine-made 1500GPH 12v Boat Marine… Rule 35A Rule-A-Matic Bilge Pump Float… Attwood Tsunami Manual Bilge Pump.

zubairabbasi992_2995511's picture

This substance is composed extremely well. Your utilization of organizing when mentioning your focuses makes your objective facts clear and straightforward. Much obliged to you. 10gbps server

khivabrothers9_3087606's picture

You did really good work. I really appreciate your new and different post. Please guys keep it up and share with us some unique post in the future… Cointame

 
qoduro_3092651's picture

Nice post thanks for sharing this information

Best Smart Water Bottles Reviews & Buying Tips

 

jadegraham816_3095386's picture

What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. we buy homes fast

asicsning_3095486's picture

they also paid a heavy price, the battlefield sacrificed three, replica versace sunglasses Grandpa also fired a shot

asicsning_3095486's picture

the injuries are very heavy, even the intestines are dragged out . http://www.kursyvaliut.ru/ Grandpa endured pain, clutching his abdomen with his left

asicsning_3095486's picture

way. Half a year later, my grandfather recovered to be discharged, mcm backpack replica Tian Xiuying tightly pulled grandfather's clothes

jordanss1231_3102771's picture

http://www.okyoo.us/allcategory.html Items 1 - 12 of 32 - Conn's HomePlus will take the stress out of your day in no time with our wide selection of recliners. Apply for our YES MONEY? credit and get approval! http://www.okyoo.us/recliner.html Relaxing has never been easier with our wide selection of rent to own recliners. Explore all of our affordable options today! http://www.okyoo.us/bar-stool.html Reclining Chairs - England Furniture - New Tazewell, TN http://www.okyoo.us/dining-chair.html Living room recliners for sale. Choose from lift, power, gliding, swivel, and rocking reclining chairs. Styles include fabric, leather, microfiber, and tufted. http://www.okyoo.us/office-chair.html Recliner Chairs & Rocking Recliners - Shop The Best Deals for Dec ... http://www.okyoo.us/ashley-recliners.html Leather Recliners - Chairs - Living Room - RC Willey http://www.okyoo.us/acme-recliners.html Patient Recliners - National Business Furniture

r3646416_2927806's picture

The codes offered here are very helpful in making the project all by me. The detailed instructions along with the image helped to understand the concept. The site has been providing a lot of such interesting topics regarding PSOC®.  snoring mouth guard

zubairabbasi992_2995511's picture

That’s a great site you folks have been carrying out there. Lucky Patcher APK

zubairabbasi992_2995511's picture

Totally awesome posting! Loads of valuable data and motivation, both of which we all need!Relay welcome your work. Car Equity Loans Fort Lauderdale

Cathy anna's picture

Thank you so much for sharing a detailed description regarding the PSoC freeRTOS task notification value. It is good that you have specified the function associated with it. It really helps us to understand the code in details. Keep up the good work.wooden spools

shashi.better_3162266's picture

Get all the Ignou synopsis, Ignou Project, Ignou mapc project, Ignou E study material, Ignou Solved Assignment and ignou mba project and synopsis.
Keep writing keep sharing

zubairabbasi992_2995511's picture

That’s a great site you folks have been carrying out there. TRAVLOO

Aron Ramzey's picture

Wow superb article. in the past article I have some doubts and confusion about PSoC FreeRTOS Projects . Now its all cleared. I was looking this program code in different sites but I didn’t get it from anywhere .finally I got it from here . Thanks Mark Saunders network printer troubleshooting

 

zubairabbasi992_2995511's picture

Your blogs and every separate material are so remarkable and lucrative it makes me come back most again. netent casino

zubairabbasi992_2995511's picture

I have a hard time describing my thoughts on content, but I really felt I should here. Your article is really great. I like the way you wrote this information. youtube converter

zubairabbasi992_2995511's picture

Awesome article! I want people to know just how good this information is in your article. It’s interesting, compelling content. Your views are much like my own concerning this subject. Entretien ménager

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.