I have the ME Labs Trainer and am working with the Chapter 9 code "Timer-Driven Assembly Language Interrupt" My goal is to understand the code well enough to port the code over to my PIC of choice and eventually develop interrupt code on my own.
In the code relating to the actual interrupt there are comments in the lines of code but no explanation in the tutorial as to what is being done. I would like to know the purpose and how these particular Hex values were arrived at. I understand the assembly commands generally but not why the code is used. The lines in question are as follows:
movlw 0xA7 ; Load W with 0xA7
addwf TMR1L, F ; Add preset value to TMR1 LSB
btfsc STATUS, 2 ; If no byte overflow, skip next instruction
incf TMR1H, F ; If byte overflow, increment MSB of TMR1
movlw 0x3C ; Load W with 0x3C
addwf TMR1H, F ; Add preset value to TMR1 MSB
Are these values used like in the previous chapter examples to adjust the time duration? If so how were they computed? I don't follow the manipulation of TMR1H byte. Why add 0xA7? Also what does incrementing the MSB do? What does adding 0x3C do? The narrative in the .pdf manual does not give any explanation what is going on with these lines.
In the code relating to the actual interrupt there are comments in the lines of code but no explanation in the tutorial as to what is being done. I would like to know the purpose and how these particular Hex values were arrived at. I understand the assembly commands generally but not why the code is used. The lines in question are as follows:
movlw 0xA7 ; Load W with 0xA7
addwf TMR1L, F ; Add preset value to TMR1 LSB
btfsc STATUS, 2 ; If no byte overflow, skip next instruction
incf TMR1H, F ; If byte overflow, increment MSB of TMR1
movlw 0x3C ; Load W with 0x3C
addwf TMR1H, F ; Add preset value to TMR1 MSB
Are these values used like in the previous chapter examples to adjust the time duration? If so how were they computed? I don't follow the manipulation of TMR1H byte. Why add 0xA7? Also what does incrementing the MSB do? What does adding 0x3C do? The narrative in the .pdf manual does not give any explanation what is going on with these lines.
Comment