Jump to content

Ian Stedman

Members
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Ian Stedman

  • Rank
    Newbrie
  1. Pic12f675 Interrupt Problem

    Thanks for your help guys. As stated, using interrupt() rather than Interrupt() and the assembly code is generated. I just knew it would be something stupid. Now I can see if the code works. Many thanks, Ian
  2. I have been using Boostbasic 6.97 to create a simple program, to respond to the interrupt on I/O pin change for a PIC12F675. Have had little luck getting it to work but delving through the assembler, the reason was clear. At the interrupt vector (0rg 0x04) my interrupt code was not present, it was nowhere within the assembler file. The external input comes from GPIO4 which is an input pin. GPIO 0/1 are LED outputs. Am I doing something stupid, here is the code? '''''''''''''''''''''''''''''''''''''''''''''' ' EdgeDetect.bas ' ' Author: Ian Stedman ' Date: 22nd May 2011 ' ' Target Device: PIC12F675A ' '''''''''''''''''''''''''''''''''''''''''''''' ' Simple software to edge detect using interruopts ' Flash an LED when edge detected. ' ' interface type: 4bit(low nibble) ' use busy signal: use time delays ' #pragma DATA _CONFIG, _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT #pragma CLOCK_FREQ 4000000 ' Clock frequency of 4 MHz ' Internal frequency is Fosc/4 or 1 MHz. Sub Interrupt() 'intcon.gie=0 intcon = intcon & 0x7F ' disable all interrupts 'if intcon.gpif =1 then gpio.0 = 0 ' Turn on LED 'intcon.gpif=0 ' clear interrupt? intcon = intcon & 0xFE 'endif 'intcon.gie=1 ' re-enable interrupts End Sub Sub main() Dim countval As Integer 'Timer count value Dim iopin As Byte ' Low level hardware setup. tmr1h = 0 ' Clear timer 1 tmr1l = 0 ansel = 0 ' Disable analogue inputs cmcon = 7 ' Set GPIO pins as digital trisio = 0x30 ' Set I/O port 0-2 as outputs. GPIO4/5 as input (counter enable) gpio = 0x01 ' Turn off LEDs t1con = 0x71 'Enable timer1, 1:8 prescaler, use T1G input pin option_reg = 0x7 'Timer 0, 1:256 prescaler. 'intcon.gie = 1 intcon = intcon | 0x88 ' Enable interrupts on I/O port change Do while 1 Call delay_ms(10) gpio.0 = 1 ' Turn LED off Loop End Sub ' End main()
×