Skip to content

Commit

Permalink
task: port to attiny88
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisstjohn committed Nov 17, 2023
1 parent 5d1316c commit 7bbf8f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion soft/lib/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,23 @@ void task_main(void)
sleep_enable();

/* We use TIMER0 with Counter A and /256 prescaler */
#if TARGET_MCU == attiny88
TCCR0A = 0x04; /* /256 */
#else
TCCR0A = 0x02; /* OCRA */
TCCR0B = 0x04; /* /256 */
#endif

/* Reset counter and set ~1ms compare */
TCNT0 = 0;
OCR0A = (uint8_t)(TIMER_SYSCLK_256_2ms/2)-1;

/* Raise interrupt on Compare Match A */
TIMSK = 0x10; /* OCIE0A */
#if TARGET_MCU == attiny88
TIMSK0 = 1<<OCIE0A;
#else
TIMSK = 1<<OCIE0A;
#endif

/* Initialise and run */
sei();
Expand Down
6 changes: 5 additions & 1 deletion soft/sample/blinky/pwm.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@
* @endcode
*/

#define PWM_GPIOS(_) _(B, 0) _(B, 1) _(B, 2) _(B, 3) _(B, 4) _(B, 5)
#if TARGET_MCU == attiny88
# define PWM_GPIOS(_) _(B, 0) _(B, 1) _(B, 2) _(B, 3) _(B, 4) _(D, 0)
#else
# define PWM_GPIOS(_) _(B, 0) _(B, 1) _(B, 2) _(B, 3) _(B, 4) _(B, 5)
#endif

0 comments on commit 7bbf8f6

Please sign in to comment.