' ------------------------------------------------------------------------- INTERRUPT NOCODE ' ------------------------------------------------------------------------- ASM SETB rb.1 'debug pin(inside interrupt) MOV myrtcc, RTCC 'preserve for comparison later CLR FSR ISR_Start: 'a rollover here rtcc would be zero, and myrtcc should be 4 'if this was an edge, myrtcc would be much higher like 230 etc CJA myrtcc,#5,@processedge 'if myrtcc > 5 then processedge JNB seenedge,@goback 'if seenedge = 0 then goback 'are we idle? inc validhigh jb validhigh.2,@goidle 'if validhigh = 4 then goidle 'the next 5 lines of code write a 0 to the fram CLRB SCK 'make sure clock is low to start with(should already be low, though) NOP CLRB SI 'put a zero on the port NOP SETB SCK 'raise clock notifying chip to read the data IJNZ lobyte, goback IJNZ hibyte, goback inc superhibyte goback: CLRB rb.1 'for debugging MOV W, #156 '255-100 = 156 RETIW goidle: CLRB seenedge 'erase the edge we saw before CLR validhigh 'reset and start over CLRB RB.1 'for debugging MOV w,#188 '255-188=67 RETIW processedge: MODE $09 'clear pending edge MOV !RB,#0 CLR RTCC 'sync to the edge! SETB seenedge 'we've now seen an edge! CLR validhigh 'next five lines of code store a 1 in the fram CLRB SCK 'make sure clock is low to start with(should already be low, though) NOP SETB SI 'put a one on the port NOP SETB SCK 'raise clock notifying chip to read the data IJNZ lobyte, retfromedge IJNZ hibyte, retfromedge inc superhibyte retfromedge: CLRB RB.1 'for debugging MOV W,#155 'WAS 188, 150 = 2.68, 160 =2.54, 170=2.26 perfect RETIW ENDASM