mitxela.com forum
Welcome. Please log in or register.

ATtiny85 Musical Greeting Card
Storm Posted: 24 Dec 2021, 03:20 AM
Avatar


Member
Posts: 2
Joined: 11-December 21
I'm currently trying to make a desk lamp for a friend that plays music when turned on using the code from https://mitxela.com/projects/musical_card.
The only problem is I have no idea how to code in assembly, but I'm trying to figure out how to disable the looping in the program, can anyone tell me what I need to change in the code to achieve this?

-------------
[top]
mit Posted: 24 Dec 2021, 10:19 PM
Avatar
yeah whatever

Admin
Posts: 538
Joined: 4-May 16
Greetings.

The looping happens when it reaches the end of the music data. The last byte of the data is zero, so when it reads a byte of zero it re-loads the program and starts over.

The loadNote routine loads the next byte of data into register r16. On line 124, we have tst r16 (test if r16 is zero) followed by brne (branch if not equal). The code between that and the dontReset label is the re-loading of the music data. Highlighted here: https://github.com/mitxela/ATtiny85-MIDI-player/blob/master/polyphony.asm#L126-L132

If you replace the highlighted lines with a simple hang, such as

hang: rjmp hang

it should stop playing when it reaches the end of the data. You'd need to reset/power cycle the chip to start it up again.

-------------
[top]
Storm Posted: 25 Dec 2021, 04:39 AM
Avatar


Member
Posts: 2
Joined: 11-December 21
The help is much appreciated, this is exactly what I was looking for.

-------------
[top]

Sign in to post a reply.