Sorry, I was just stripping out the interupt bits (since they are compiling fine now), but yes, I can see how that's confused you all!
Anyway, to show off my new found "box" skills, here you go...
My (noob) take here is that, when a key is pressed, the interrupt routine jumps to the Get_char - this keyboard 'keyed' "data" is then stored in the variable mybyte - but what will the actual contents of mbyte be ? For example if I press a "1" key on the keyboard will it be 00000001 (unlikely!), or 00110001 (binary for 49 - the ASCII code for the number "1"). Once I can figure out this bit, then I can make sure my "if" takes account of it. (that'll be my next question!) Also, the line I bolded...I was trying to see onscreen what the content of the variable mybyte was - but nothing was output?Code:@MyConfig = _XT_OSC & _WDT_ON & _MCLRE_ON & _CP_OFF @MyConfig = MyConfig & _BOR_OFF @ __config MyConfig INCLUDE "DT_INTS-14.bas" ; Base Interrupt System INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts DEFINE OSC 4 DEFINE HSER_SPBRG 25 DEFINE HSER_TXSTA 24h DEFINE HSER_CLROERR 1 ANSELH=0 ANSEL=0 CM1CON0 =0 CM2CON0 =0 CM2CON1 =0 adcon1=0 TRISB.6 = 1 TRISB.7 = 0 TRISC=%00000000 ; set all Port C pins as outputs rcsta.7=1 'SPEN serial port enable bit low portc.0 low portc.1 low portc.2 low portc.3 mybyte var byte '::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::: ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RX_INT, _Get_char, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM '::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::: @ INT_ENABLE RX_INT ; enable external (INT) interrupts loop: if mybyte="1" then hserout ["got it!"] endif if mybyte=!"1" then hserout ["DIDN'T GET IT!",13,10] hserout [mybyte,13,10] ' (tried to add in this line to see onscreen what the content of mybyte is - nothing output!) PAUSE 499 mybyte=0 endif goto loop '---[USART RX - interrupt handler]--------------------------------------------------- Get_char: hserin 100,noreceived,[mybyte] 'Get byte noreceived: 'or if timeout return @ INT_RETURN
BTW The low portc.0 low portc.1 are in there because I have a Microchip low pin count demo board & my (eventual) target for today is to get some LEDs to light up when certain keys on my PC keyboard are pressed - I'm a simple kind of easy to please chap, who marvels at this kind of thing & insists all around me marvel too! (though it irks my two year old something rotten when I interrupt his Thomas The Tank Engine viewing)




Bookmarks