# Atmega328pb

**URL:** <https://forums.freertos.org/t/atmega328pb/15204>\
**Category:** Kernel\
**Tags:** debug, tutorial\
**Created:** [June 1, 2022, 7:43am UTC](https://forums.freertos.org/t/atmega328pb/15204 "2022-06-01T07:43:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohamedSoliman-pixel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/mohamedsoliman-pixel/32/2585_2.png) [@mohamedSoliman-pixel](https://forums.freertos.org/u/mohamedSoliman-pixel)\
**Post date:** [June 1, 2022, 7:43am UTC](https://forums.freertos.org/t/atmega328pb/15204/1 "2022-06-01T07:43:34Z")

</div>

Hello everybody,  
It’s my first time to use Free RTOS and i am trying to use it with atmega328pb and microchip studio. At first run I got an error " ‘TIMSK’ undeclared (first use in this function)" so I have changed it TIMSK1. Also these definitions were checked  
#define portCLEAR\_COUNTER\_ON\_MATCH ( ( uint8\_t ) 0x08 )  
#define portPRESCALE\_64 ( ( uint8\_t ) 0x03 )  
#define portCLOCK\_PRESCALER ( ( uint32\_t ) 64 )  
#define portCOMPARE\_MATCH\_A\_INTERRUPT\_ENABLE ( ( uint8\_t ) 0x10 )  
but still doesn’t run as expected. the task is simple blinking task that uses vTaskDelay() function but no blink happened.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [June 1, 2022, 8:48am UTC](https://forums.freertos.org/t/atmega328pb/15204/2 "2022-06-01T08:48:27Z")

</div>

Is your tick interrupt working as expected? You can check that by breaking in debugger and examining the value of `xTickCount`.

---

<div class="post-metadata">

**Author:** ![hamblingreg52](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/hamblingreg52/32/1471_2.png) [@hamblingreg52](https://forums.freertos.org/u/hamblingreg52)\
**Post date:** [June 1, 2022, 10:32am UTC](https://forums.freertos.org/t/atmega328pb/15204/3 "2022-06-01T10:32:53Z")

</div>

> [@aggarg](#):
>
> You can check that by breaking in debugger and examining the value of `xTickCount`.

I have done the same but still, I cannot confirm whether the tick interrupt is working or not.

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [June 1, 2022, 10:42am UTC](https://forums.freertos.org/t/atmega328pb/15204/4 "2022-06-01T10:42:02Z")

</div>

so what are the results of that test? If xTickCount is incrementing, your timer is working, otherwise it is not. What is missing?

---

<div class="post-metadata">

**Author:** ![mohamedSoliman-pixel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/mohamedsoliman-pixel/32/2585_2.png) [@mohamedSoliman-pixel](https://forums.freertos.org/u/mohamedSoliman-pixel)\
**Post date:** [June 3, 2022, 8:56pm UTC](https://forums.freertos.org/t/atmega328pb/15204/5 "2022-06-03T20:56:18Z")

</div>

I don’t know what happened but I made a new test project and I found the xtickcount increasing and it is working now. I am testing with proteus the simulation is very fast, I adjust the blink to be every 5 seconds but it seems to blink every 1 second or less.  
here are the code used to make the delay  
vTaskDelay(pdMS\_TO\_TICKS(5000));

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [June 4, 2022, 12:32pm UTC](https://forums.freertos.org/t/atmega328pb/15204/6 "2022-06-04T12:32:01Z")

</div>

Have you configured `configTICK_RATE_HZ` i.e. does it match the tick frequency? Another possibility to look out for is that sometimes simulations are faster and therefore, one second in simulation may be much less in real time.

---

<div class="post-metadata">

**Author:** ![mohamedSoliman-pixel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/mohamedsoliman-pixel/32/2585_2.png) [@mohamedSoliman-pixel](https://forums.freertos.org/u/mohamedSoliman-pixel)\
**Post date:** [June 5, 2022, 7:24pm UTC](https://forums.freertos.org/t/atmega328pb/15204/7 "2022-06-05T19:24:26Z")

</div>

It is configured to be 1000, is it right configuration.?

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [June 6, 2022, 5:33am UTC](https://forums.freertos.org/t/atmega328pb/15204/8 "2022-06-06T05:33:53Z")

</div>

It should be configured to your tick frequency. So you need to check what is your tick frequency.
