SH4 Watchdog Timer Driver

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1874
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 80 times
Been thanked: 61 times
Contact:

SH4 Watchdog Timer Driver

Post by GyroVorbis »

Hey guys, I was perusing the KOS codebase the other day, digging into some Timer stuff when I saw a comment stating "WDT is not supported," which I thought was kind of bullshit... So I wrote a driver for it which just got merged into KOS. I also included an example as well. :lol:

https://github.com/KallistiOS/KallistiO ... 918eb428fd.

Only 2 of the 4 supported modes are relevant to us: The watchdog and interval timer modes.

Watchdog mode basically works the same way a standard watchdog timer works, where a reset signal is sent after a counter overflow. My API lets you configure which reset interrupt is generated (MANUAL, POWER_ON), plus the clock divider for setting the counter frequency... The only problem is that even with the largest divider, the thing still runs so fast that a reset is generated about every 5ms, making it still unsuited for a gamedev frame-based WDT... It's just so damn speedy!

What IS particularly useful is the interval timer mode, which lets you use the WDT basically as an extra generic timer with up to 41us resolution. My API lets you configure the timeout interval in microseconds and then invokes your callback as soon as the interval has elapsed, within 41us of the requested timeout period.

Since KOS already reserves two of the general-purpose TMU peripherals for housekeeping, I'm hoping the WDT can be useful to some people as another general-purpose timer.

NOTE: I have spoken with many emulator authors and NOBODY has bothered to emulate this damn thing, since apparently it was never used... At very worst case, you can use it to detect whether you're running on an emulator or not. :lol:
These users thanked the author GyroVorbis for the post:
|darc|
Post Reply