Hi all
I've been trying to control a triac using an interrupt on RB0 and going to an interrupt handler - been basing it on the discussion surrounding Mr E's lamp dimmer code.
My input pulse train to RB0 is clean - 8.3 ms apart as it should be. However, the output pulses are about 90 MS apart. Am I misunderstanding how to configure the interrupts, doing something else foolish or what? Any help would be appreciated...Code:'**************************************************************** '* Name : triac_force.pbp * '* Author : Alec Noble * '* Notice : Copyright (c) 2011 Alec Noble * '* : All Rights Reserved * '* Date : 6/18/2011 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** @ DEVICE PIC16F819, WDT_OFF, LVP_OFF, PWRT_ON, PROTECT_OFF, BOD_OFF, INTRC_OSC_NOCLKOUT DEFINE OSC 8 ' Set the Xtal frequency to 8mHz OSCCON = %01110100 ' ** Setup the interrupts ** INTCON.7 = 1 'GIE - enable global interrupts INTCON.4 = 1 'Enable RB0 interrupt on interrupt goto AC_detect trisa = %11111111 'Port A all inputs trisb = %00000001 'Port B.0 input, all others outputs main: goto main ' ' Interrupt routine called by ACLine (RB0) pin state change ' disable AC_Detect: pauseus 100 pulsout portb.1, 25 INTCON.1=0 ' Clear interrrupt flag resume enable
Thanks
Alec




Bookmarks