Flowcode V 4.5 PIC16F887
Hi,
I am using a TMR1 interrupt activated from the internal clock. When this is enabled Flowcode sets the LP Oscillator,
(st_bit(t1con,T1OSCEN);), which causes RC0 and RC1 to be set as inputs. I am outputing PWM on RC1 (CCP2). I can rectify all this using C code each time the interrupt is enabled but is there a way to alter the Flowcode TMR1 interrupt code?
Why does this bit set in the first place if internal clock is set?
Thanks,
Dave.
Timer 1 interrupt
Moderator: Benj
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Timer 1 interrupt
Hi Enamul,
The code is large and commercially sensitive.
The C generated by flowcode is:
The line st_bit(t1con,T1OSCEN); turns on the LP oscillator which is not needed for internal clock (fOsc/4) source.
How to stop it being generated?
Dave
The code is large and commercially sensitive.
The C generated by flowcode is:
Code: Select all
//Interrupt
//Interrupt: Enable TMR1
st_bit(intcon,PEIE);
st_bit(t1con,T1OSCEN);
st_bit(t1con,TMR1ON);
cr_bit(t1con,TMR1CS);
t1con = t1con & 0x0F;
st_bit(intcon,GIE);
st_bit(pie1, TMR1IE);
How to stop it being generated?
Dave
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Timer 1 interrupt
Ok. No problem. I want to see the code as it is Flowcode v4 not v5. In V5 it is easy to edit without going to FCD but in V4 you have to edit in FCD. so please find out PIC16f887.FCD file in v4 FCD folder in program files. you should be able to find out the following piece of code..
Change to the following in the Opt1_2 portion
Let me know how it's going. I haven't got enough time to look at datasheet to verify whether it's the only way or not. Seems you are competent 
Edit:Need to restart flow-code to have the effect of change in FCD.
Code: Select all
[TMR1]
;NOTE: this osc is enabled and turned on as part of the Opt1 code
Name="TMR1"
FlagReg=
FlagBit=
HandlerCode="#ifndef MX_INTHANDLER_pir1_TMR1IF\n#define MX_INTHANDLER_pir1_TMR1IF\nif (ts_bit(pir1, TMR1IF) && ts_bit(pie1, TMR1IE))\n{\n\t#ifdef USE_FLOWCODE_ICD\n\t\textern char ICD_Interrupt_Enable = 1;\n\t#endif\t\n\tFCM_%n();\n\tcr_bit(pir1, TMR1IF);\n\t#ifdef USE_FLOWCODE_ICD\n\t\textern char ICD_Interrupt_Enable = 0;\n\t#endif\t\n}\n#else\n#warning "This interrupt has previously been enabled, so the macro <%n> may never get called."\n#endif\n"
UseExplicitHandlerCode=1
UseExplicitEnableCode=1
EnReg=
EnBit=
EnableCode="st_bit(pie1, TMR1IE);\n"
DisableCode="cr_bit(pie1, TMR1IE);\n"
OptCnt=2
PrescaleOpt=2
MaxTimerOverflow=65536
Opt1="Clock Source Select"
Opt1Cnt=2
Opt1_1="Transition on T1CKI pin"
Opt1_1Val="st_bit(intcon,PEIE);\nst_bit(t1con,T1OSCEN);\nst_bit(t1con,TMR1ON);\nst_bit(t1con,TMR1CS);\n"
Opt1_2="Internal clock (Fosc/4)"
Opt1_2Val="st_bit(intcon,PEIE);\nst_bit(t1con,T1OSCEN);\nst_bit(t1con,TMR1ON);\ncr_bit(t1con,TMR1CS);\n"
Opt2="Prescaler Rate"
Opt2Cnt=4
Opt2_1="1:1"
Opt2_1Val="t1con = t1con & 0x0F;\n"
Opt2_2="1:2"
Opt2_2Val="t1con = (t1con & 0x0F) | 0x10;\n"
Opt2_3="1:4"
Opt2_3Val="t1con = (t1con & 0x0F) | 0x20;\n"
Opt2_4="1:8"
Opt2_4Val="t1con = (t1con & 0x0F) | 0x30;\n"
Code: Select all
Opt1_2="Internal clock (Fosc/4)"
Opt1_2Val="st_bit(intcon,PEIE);\nst_bit(t1con,TMR1ON);\ncr_bit(t1con,TMR1CS);\n"

Edit:Need to restart flow-code to have the effect of change in FCD.
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
Re: Timer 1 interrupt
Actually in Flowcode couple of things are in FCD and most are in component c code. There is no clear guide line where you can get this kind of problem's solution yet; but spending couple of week in forum I believe you will know where to look for. I am in the forum for last 4 months so it's not that much tough to know.
If you know where to look then it will not be trial and error issue rather you can dig that out easily.
If you know where to look then it will not be trial and error issue rather you can dig that out easily.