i need to use the timer 1 gate feature for pulse measurement as i need it to be done in the background whilst i do other things.
i have used it before but sadly that was on my last pc hard drive that decided to die taking most of my work and ported files so i no longer have that to reference to as it was a good working example.
i generally do think im doing something wrong as im sure i may have had issues before that took forever to catch and rectify but for the life of me i cant remember what it was.
ok so its all working now, it seems that i have to not use a mix of gcb built in routines if im also playing with the register bits for those certain functions.
i remember this from before on something else but its all working now with timer1 gate background capturing a pulse then setting interrupt to update variable for main routine to send out the usart whenever a new capture has been processed.
... it seems that i have to not use a mix of gcb built in routines if im also playing with the >>register bits for those certain functions.
I have run into the same thing as well. Some of the GCB functions may do more than what the command name implies. This is especially true regarding timer.h and interrupts . I have found it best not to mix things up whenever possible.
Now about losing your files ...... I sync up all of my important files with a thumb drive at the end of each day. I also recently set up a scheduled task to back up all of my new and changed data files to the "Cloud" every day at 4:00 AM. (due to a recent incident with someone with a can of spray paint and a bottle of bleach!)
I once "lost" some very important stuff that represented hundreds of hours or work when a CPU coolant line blew and "antifreeze" spewed all over the inside of the PC taking out both hard drives and frying the motherboard.
I was not too happy about paying $350.00 to a recovery service to retrieve the data, not to mention the down time involved, Had to learn the hard way.
William
Last edit: William Roth 2015-10-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i definately need to setup a good system for ensuring back ups, i dont care about losing most of my code but this one piece is my "baby" lol.
thankfully though i have been getting it slowly rewritten and debugged but that is a very long journey for this particular code,but along the way i have been using the individual registers for the chips peripherals and setup, dont get me wrong the built in routines are used alot for most projects but i have to get in the habit of solely using the registers as that may be the only way to get specific things done very quickly.
i have never had the misfortune of a liquid cooled system blowing on me yet but thats a hit to the wallet that is not much appreciated before you factor in and have to do those hours again to get that code back, definately a very disheartening experience when alot of work gets lost, i have lost count of the hours i have put into this code as well but probably up their in the high numbers of hours.
so far with this code now its all interrupt driven for pulse capture with another timer running behind the T1G to kick in for failsafe if the signal is lost, initial capture with the logic analyzer shows one missed framerate and it goes into failsafe mode ( approx 23 ms), sadly still so much to go but its all learning lol.
tony
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i need to use the timer 1 gate feature for pulse measurement as i need it to be done in the background whilst i do other things.
i have used it before but sadly that was on my last pc hard drive that decided to die taking most of my work and ported files so i no longer have that to reference to as it was a good working example.
i generally do think im doing something wrong as im sure i may have had issues before that took forever to catch and rectify but for the life of me i cant remember what it was.
~~~~
#chip 12f1840, 16
#config MCLRE_OFF
;USART settings
#define USART_BAUD_RATE 9600
#define USART_BL0CKING
;set alternate pin locations:
set APFCON = b'00000011'
;Input Pin and Direction
#define rx_in PORTA.3
Dir rx_in In
Dir PORTA.4 Out 'send on Pin 4
Dir PORTA.5 In 'receive on Pin 5
;Init timer and clear value to zero
InitTimer1 Osc, PS1_4 ; timer1 gate used for rx signal input capture
ClearTimer 1 ; clear timer1 register value
;Init timer1 gate and clear interrupt flags and timer1
;T1GSEL = 1
;T1CON = b'01000001'
T1GCON = b'11010000'
TMR1GIF = 0
;TMR1IF = 0
TMR1H = 0
TMR1L = 0
Dim pulse_value As WORD
Dim pulse_flag As bit
on interrupt Timer1gate call pulse_captured
pulse_value = 0
pulse_flag = 0
T1GGO = 1
; Main Program starts here
Do
Loop
sub Pulse_captured
if TMR1GIF = 1 Then
end if
end sub
~~~~
tony
Last edit: tony golding 2015-10-11
ok so its all working now, it seems that i have to not use a mix of gcb built in routines if im also playing with the register bits for those certain functions.
i remember this from before on something else but its all working now with timer1 gate background capturing a pulse then setting interrupt to update variable for main routine to send out the usart whenever a new capture has been processed.
~~~~
#chip 12f1840, 16
;#Config PLLEN_ON
#config MCLRE_OFF
;USART settings
#define USART_BAUD_RATE 9600
#define USART_BL0CKING
;set alternate pin locations
APFCON.3 = 1 ; Timer1 gate input on RA3
;Input Pin and Direction
#define rx_in PORTA.3
Dir rx_in In
Dir PORTA.4 Out 'send on Pin 4
Dir PORTA.5 In 'receive on Pin 5
; Timer1 and gate settings
T1CON = b'01000001'
T1GCON = b'11010000'
TMR1GIF = 0
TMR1H = 0
TMR1L = 0
Dim pulse_value As WORD
Dim pulse_flag As bit
pulse_value = 0
pulse_flag = 0
GIE = 1
PEIE = 1
TMR1GIE = 1
T1GGO = 1
; Main Program starts here
Do
Loop
sub Interrupt
if TMR1GIF = 1 Then
end if
end sub
~~~~
tony
I have run into the same thing as well. Some of the GCB functions may do more than what the command name implies. This is especially true regarding timer.h and interrupts . I have found it best not to mix things up whenever possible.
Now about losing your files ...... I sync up all of my important files with a thumb drive at the end of each day. I also recently set up a scheduled task to back up all of my new and changed data files to the "Cloud" every day at 4:00 AM. (due to a recent incident with someone with a can of spray paint and a bottle of bleach!)
I once "lost" some very important stuff that represented hundreds of hours or work when a CPU coolant line blew and "antifreeze" spewed all over the inside of the PC taking out both hard drives and frying the motherboard.
I was not too happy about paying $350.00 to a recovery service to retrieve the data, not to mention the down time involved, Had to learn the hard way.
William
Last edit: William Roth 2015-10-14
i definately need to setup a good system for ensuring back ups, i dont care about losing most of my code but this one piece is my "baby" lol.
thankfully though i have been getting it slowly rewritten and debugged but that is a very long journey for this particular code,but along the way i have been using the individual registers for the chips peripherals and setup, dont get me wrong the built in routines are used alot for most projects but i have to get in the habit of solely using the registers as that may be the only way to get specific things done very quickly.
i have never had the misfortune of a liquid cooled system blowing on me yet but thats a hit to the wallet that is not much appreciated before you factor in and have to do those hours again to get that code back, definately a very disheartening experience when alot of work gets lost, i have lost count of the hours i have put into this code as well but probably up their in the high numbers of hours.
so far with this code now its all interrupt driven for pulse capture with another timer running behind the T1G to kick in for failsafe if the signal is lost, initial capture with the logic analyzer shows one missed framerate and it goes into failsafe mode ( approx 23 ms), sadly still so much to go but its all learning lol.
tony