I'm trying to use the DMC IRQ in an unusual way, and I'm not sure why it's not working. So I don't know if it can't be used like this, or if I'm simply doing something wrong.
What I'm trying to do is enable DMC IRQ, play a sample, and continually retrigger that sample to prevent it from generating an IRQ. I'm trying this because I'm making a bit-banged UART that can poll in the tightest loop possible without getting hung up if the other end isn't responding.
The result I'm getting is that I seem to get an IRQ when I retrigger the sample. I've tried things a few different ways, but I always seem to get interrupted.
Here's how I set it up, this part by itself seems OK. I can run this, do an SEI when communication begins, and it's fine.
But instead if I try to retrigger the sample, I seem to get an IRQ. I've tried different variations of the code with the same result, this is probably the most elaborate one of them:
Another interesting thing is that the retrigger code ideally would need to fit within 14 CPU cycles.
The IRQ routine itself reads $4015 to acknowledge the IRQ. The interrupt timer needed is something like 2 seconds long. Shorter time out would be OK, but NMI is out of the question because I'd have to sync to it. And frame IRQ, I don't know how it works exactly but I believe that's something that I can't reset, correct? If I have to sync up with it, it's not usable.
It's not a huge deal. It works if I don't try to retrigger it, and that's good enough for like 95% of the time I would need it. I can make a work-around that will mostly take care of the other situations, but it would be great if I could never leave the NES vulnerable to being locked up like that. I guess if I really had to know I'd be turning to Visual 2A03, but I haven't really used that enough to know exactly what I'd be looking for. This is already kind of a side-quest of a side-quest. But I was wondering if anyone else wanted to look at this, correct my misunderstanding of DMC IRQ, or shed any light on the subject otherwise.
What I'm trying to do is enable DMC IRQ, play a sample, and continually retrigger that sample to prevent it from generating an IRQ. I'm trying this because I'm making a bit-banged UART that can poll in the tightest loop possible without getting hung up if the other end isn't responding.
The result I'm getting is that I seem to get an IRQ when I retrigger the sample. I've tried things a few different ways, but I always seem to get interrupted.
Here's how I set it up, this part by itself seems OK. I can run this, do an SEI when communication begins, and it's fine.
Code:
lda #$40
sta $4017
lda #$80
sta $4010
lda #$3f
sta $4013
lda #$10
sta $4015
sta $4015
cli
sta $4017
lda #$80
sta $4010
lda #$3f
sta $4013
lda #$10
sta $4015
sta $4015
cli
But instead if I try to retrigger the sample, I seem to get an IRQ. I've tried different variations of the code with the same result, this is probably the most elaborate one of them:
Code:
sei
lda #0
sta $4015
lda #$10
sta $4015
lda $4015
nop
cli
lda #0
sta $4015
lda #$10
sta $4015
lda $4015
nop
cli
Another interesting thing is that the retrigger code ideally would need to fit within 14 CPU cycles.
The IRQ routine itself reads $4015 to acknowledge the IRQ. The interrupt timer needed is something like 2 seconds long. Shorter time out would be OK, but NMI is out of the question because I'd have to sync to it. And frame IRQ, I don't know how it works exactly but I believe that's something that I can't reset, correct? If I have to sync up with it, it's not usable.
It's not a huge deal. It works if I don't try to retrigger it, and that's good enough for like 95% of the time I would need it. I can make a work-around that will mostly take care of the other situations, but it would be great if I could never leave the NES vulnerable to being locked up like that. I guess if I really had to know I'd be turning to Visual 2A03, but I haven't really used that enough to know exactly what I'd be looking for. This is already kind of a side-quest of a side-quest. But I was wondering if anyone else wanted to look at this, correct my misunderstanding of DMC IRQ, or shed any light on the subject otherwise.