Don_dody
Full Member level 1

The circuit that I've built:

The code:
The simulation result:

My questions:
1. Is my code right?
2. What's wrong with green wave in the oscilloscope? Why I didn't get something like this :


The code:
Code:
#include <mega8535.h>
#include <delay.h>
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
PORTB=0x00;
delay_ms(5); // firing triac 6 ms after zero cross detected
PORTB=0x01;
delay_us(1); // firing pulse width 1 us
PORTB=0x00;
}
void main(void)
{
PORTB=0x00;
DDRB=0x01; // PORTB.0 as output
GICR|=0x40; // INT0
MCUCR=0x01;
MCUCSR=0x00;
GIFR=0x40;
// Global enable interrupts
#asm("sei")
while (1)
{
}
}
The simulation result:

My questions:
1. Is my code right?
2. What's wrong with green wave in the oscilloscope? Why I didn't get something like this :

Last edited: