adding new word variable ?



THE BOOK of DT's INTERRUPTS is an organization of interrupt service routines and other works written by Darrel Taylor, RIP.

Interrupt routines are arranged per Darrel's original list. Darrel Taylor's Instant Interrupts are an extension of the work of Tim Box whom in October of 2002 wrote INT_CTRL.pbp

Many of the forum members felt this is a long overdue project.

THE BOOK of DT's INTERRUPTS
will be a valuable resource and a tribute to Darrel Taylor the "Fanatical Contributor".

THE BOOK of DT's INTERRUPTS is located at http://dt.picbasic.co.uk/

+ Reply to Thread
Results 1 to 5 of 5
  1. #1

    Angry adding new word variable ?

    I have strange problem which get me worried about all my working I doing .

    when I adding new variable of type word then my programm not working well so the interrupt is not accurate and get encoding number wrong but when i remove this variable then all return working alright.

    I don't know what is the reason ?

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by iugmoh View Post
    I have strange problem which get me worried about all my working I doing .
    when I adding new variable of type word then my programm not working well so the interrupt is not accurate and get encoding number wrong but when i remove this variable then all return working alright.
    I don't know what is the reason ?
    And neither will we without seeing some code!

  3. #3


    Did you find this post helpful? Yes | No

    Lightbulb

    here is the main part of my code

    INCLUDE "modedefs.bas"
    DEFINE LCD_DREG PORTD 'LCD data port
    DEFINE LCD_DBIT 4 'LCD data starting bit 0 at RD4 to RD7
    DEFINE LCD_RSREG PORTD 'LCD register select port
    DEFINE LCD_RSBIT 2 'LCD register select bit
    DEFINE LCD_EREG PORTD 'LCD enable port
    DEFINE LCD_EBIT 3 'LCD enable bit
    DEFINE LCD_BITS 4 'LCD bus size 4 or 8
    DEFINE LCD_LINES 4 'Number lines on LCD
    DEFINE OSC 4 ' We're using a 4 MHz oscillator
    symbol reg_but=portb.4
    symbol fin_but=portb.5
    symbol can_but=portb.6


    symbol qobol1=porta.1
    symbol qobol2=porta.2
    symbol qobol3=porta.3
    symbol qobol4=porta.4

    symbol malya1=porta.5
    symbol malya2=portb.7


    adcon1=7 ; All port A is digital
    symbol DIN=PORTE.0 ; pin 1 of max7219
    symbol LOAD=PORTE.1 ; pin 12 of max7219
    symbol CLK=PORTE.2 ; pin 13 of max7219
    symbol initial=porta.0
    trisa=255
    TRISE=0
    input initial

    ID1 var bit[253] ; first array contain 253 bits rest from 0 tp 252
    ID2 var bit[99] ; second array contain 99 bits from 0 98 total are 253+99=352
    ID var byte[9]
    char var byte
    counter1 var byte ; be attention
    counter2 var byte ; be attention
    i var byte
    digit var byte
    num var byte

    address var byte
    datareg var byte

    number1 var word
    number2 var word
    number3 var word
    number4 var word
    maxnumber var word


    load=1


    Symbol RS232_out = portd.0 ' RB0 is RS232 output
    Symbol RS232_in = portd.1 ' RB1 is RS232 input

    symbol clock_barcode=portb.0 ; clock of barcode reader ps/2
    symbol data_barcode=portb.1 ; data of barcode reader ps/2
    symbol pstrobe=portb.2 ; strobe of parallel port
    symbol data_printer=portc ; data for printer
    symbol busy=portb.3 ; busy signal


    Clr CON 1 ' Serial LCD command to clear LCD
    LINE1 CON 128 ' Line #1 of serial LCD
    LINE2 CON 192 ' Line #2 of serial LCD
    LINE3 CON 148 ' Line #3 of serial LCD
    LINE4 CON 212 ' Line #4 of serial LCD
    Ins CON 254 ' Instruction for LCD command-mode



    input clock_barcode
    input data_barcode
    output portd.1
    input reg_but
    input fin_but
    input can_but
    input malya2

    input busy
    output pstrobe
    trisc=0 ; data of parallel port
    pstrobe=1


    counter1=0
    counter2=0
    char=0
    i=0
    ;;;;;;;;;;;;;;;; get numbers for eeprom
    read 0,number1
    read 1,number2
    read 2,number3
    read 3,number4

    gosub Init_MAX
    gosub disp1:gosub disp2:gosub disp3:gosub disp4

    pause 2000 ; time for lcd to turn on

    INTCON = %00010000 ; Enable RB0 interrupt
    OPTION_REG = %10000000 ; falling edge of clock
    ON INTERRUPT GOTO reg_id
    INTCON = %10010000 ; Enable RB0 interrupt
    lcdout Ins,clr,INS,Line1,"Please Ins. ID card"
    goto main

    ;;;;;;; interrupt service routine
    DISABLE ' Disable interrupts in handler
    reg_id:
    intcon.1=0 ; reset int
    if clock_barcode=0 then ; test falling edge
    if counter1<253 then
    id1[counter1]=data_barcode
    counter1=counter1+1
    else
    id2[counter2]=data_barcode
    counter2=counter2+1
    ;;;;;;; test

    endif
    endif

    RESUME ' Return to main program
    ENABLE ' Enable interrupts after handler
    ;;;;;;;;;;;;;;;;;


    Main:

    ;;; automatic display ID card after interrupt finished
    if counter2>98 then ;;
    SEROUT RS232_out, T9600, ["Student registered",13,10]
    LCDout ins,clr,ins,line1," CCAST ",Ins,line2,"Your ID:"
    SEROUT RS232_out, T9600, ["Your ID:",13,10]
    gosub ID_decode
    ;;;;;;;;;;;;;;;;

    ;;;;;;;;;;;;

    else
    if initial=0 then
    gosub initial_system

    else

    gosub monitor_buttons

    endif
    endif


    goto main ' Remain in loop

    end

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by iugmoh View Post
    here is the main part of my code
    end
    So what's the problem?

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    INCLUDE "modedefs.bas"
    DEFINE LCD_DREG PORTD 'LCD data port
    DEFINE LCD_DBIT 4 'LCD data starting bit 0 at RD4 to RD7
    DEFINE LCD_RSREG PORTD 'LCD register select port
    DEFINE LCD_RSBIT 2 'LCD register select bit
    DEFINE LCD_EREG PORTD 'LCD enable port
    DEFINE LCD_EBIT 3 'LCD enable bit
    DEFINE LCD_BITS 4 'LCD bus size 4 or 8
    DEFINE LCD_LINES 4 'Number lines on LCD
    DEFINE OSC 4 ' We're using a 4 MHz oscillator
    reg_but var portb.4:fin_but var portb.5:can_but var portb.6 : qobol1 var porta.1 : qobol2 var porta.2 : qobol3 var porta.3 : qobol4 var porta.4:malya1 var porta.5
    malya2 var portb.7:adcon1=7 : din var porte.0:load var porte.1:clk var porte.2:initial var porta.0:trisa=255:trise=0:input initial:id1 var bit[253]:id2 var bit[99]
    id var byte[9]:char var byte:counter1 var byte:counter2 var byte:i var byte : digit var byte:num var byte:address var byte : datareg var byte:number1 var word
    number2 var word:number3 var word:number4 var word:maxnumber var word:load=1:rs232_out var portd.0:rs232_in var portd.1:clock_barcode var portb.0
    data_barcode var portb.1 : pstrobe var portb.2:data_printer var portc : busy var portb.3:clr con 1:line1 con 128:line2 con 192:line3 con 148:line4 con 212
    ins con 254:input clock_barcode:input data_barcode : output portd.1:input reg_but:input fin_but:input can_but:input malya2:input busy : output pstrobe:trisc=0
    pstrobe=1:counter1=0:counter2=0:char=0:i=0
    ;;;;;;;;;;;;;;;; get numbers for eeprom
    read 0,number1:read 1,number2:read 2,number3:read 3,number4:gosub init_max:gosub disp1:gosub disp2:gosub disp3:gosub disp4 : pause 2000 : option_reg=$80
    intcon=$90
    ON INTERRUPT GOTO reg_id
    lcdout Ins , clr , INS , Line1 , "Please Ins. ID card" : goto main
    ;;;;;;; interrupt service routine
    DISABLE ' Disable interrupts in handler
    reg_id:
    intcon.1=0 ;reset int HOW DO YOU KNOW THAT THE PARTICULAR INTERRUPT YOU WANT ACTUALLY FIRED? YOU'RE JUST ASSUMING ONE FIRED OFF, NOT THE ONE YOU WANTED
    if clock_barcode=0 then ; test falling edge
    if counter1<253 then
    id1[counter1]=data_barcode : counter1=counter1+1
    else
    id2[counter2]=data_barcode : counter2=counter2+1
    ;;;;;;; test
    endif
    endif
    RESUME ' Return to main program
    ENABLE ' Enable interrupts after handler
    ;;;;;;;;;;;;;;;;;
    Main:
    ;;; automatic display ID card after interrupt finished
    if counter2>98 then ;;
    serout rs32_out,t9600,["Student registered",13,10]:lcdout ins,clr,ins,line1," CCAST ",ins,line2,"Your ID:":serout rs232_out,t9600,["Your ID:",13,10]
    gosub ID_decode
    ;;;;;;;;;;;;;;;;
    else
    if initial=0 then
    gosub initial_system
    else
    gosub monitor_buttons
    endif
    endif
    goto main ' Remain in loop
    end

    See notes in code above
    Last edited by skimask; - 21st February 2008 at 00:36.

Similar Threads

  1. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  2. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  3. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th July 2008, 23:19
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 15:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts