rb0/int
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
rb0/int
Hallo
I work with trm0int > timer0_int macro .......
it works ok.
only portb-0 is nc. so i want go this way.
I add rb0_risig edge > macro b0_int = set flagx
I add rb0_falling edge > b0_int = set flagx
in the main-menue i want reset flagx in the makro rb0_int_is
my problem the flagx alltim set??????
can you help me?
regards wolfgang
I work with trm0int > timer0_int macro .......
it works ok.
only portb-0 is nc. so i want go this way.
I add rb0_risig edge > macro b0_int = set flagx
I add rb0_falling edge > b0_int = set flagx
in the main-menue i want reset flagx in the makro rb0_int_is
my problem the flagx alltim set??????
can you help me?
regards wolfgang
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
rb0_int
Hallo
To day i show with the mc-debugger for this problem.
I found out,without interrupt on portb 0 each time it stoop
on the breakpoint in my rb0_int macro.Itest it with falling and
rising edge....it is the same.
Is these a mistake of my ???? please give me a answer.
thanks wolfgang
To day i show with the mc-debugger for this problem.
I found out,without interrupt on portb 0 each time it stoop
on the breakpoint in my rb0_int macro.Itest it with falling and
rising edge....it is the same.
Is these a mistake of my ???? please give me a answer.
thanks wolfgang
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello Wolfgang
I think that if you want to detect both edges you must do the following.
1) start the interrupt to detect the rising edge
2) when interrupt starts
3) disable the rising edge interrupt
4) start the interrupt to detect the falling edge
5) when interrupt starts
6) disable the falling edge interrupt
alternativley you can use this line of C code to swap between rising and falling edge detection. Both interrupts will trigger the same macro.
set_bit (option_reg,6); //Interrupt on rising edge
or
clear_bit (option_reg,6); //Interrupt on falling edge
I think that if you want to detect both edges you must do the following.
1) start the interrupt to detect the rising edge
2) when interrupt starts
3) disable the rising edge interrupt
4) start the interrupt to detect the falling edge
5) when interrupt starts
6) disable the falling edge interrupt
alternativley you can use this line of C code to swap between rising and falling edge detection. Both interrupts will trigger the same macro.
set_bit (option_reg,6); //Interrupt on rising edge
or
clear_bit (option_reg,6); //Interrupt on falling edge
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
rb0_int
Hallo Steve
I send you the code at 19.09.07........
I change on my board pic 18F4620:
port rb0_pins rb1 to rb3 = free >> rb0 = int_switch
port rb4 = output
the rb0_int works ok.
after this i input steep by steep my ather programcode
and after i input the Komponent-Makro "Sample_ADC(0)"
i have the same effect , alltime turn into interrupt_routine rb0_int .
What can i make in case of this?
I hope jou give me a answer.
Thanks wolfgang
I send you the code at 19.09.07........
I change on my board pic 18F4620:
port rb0_pins rb1 to rb3 = free >> rb0 = int_switch
port rb4 = output
the rb0_int works ok.
after this i input steep by steep my ather programcode
and after i input the Komponent-Makro "Sample_ADC(0)"
i have the same effect , alltime turn into interrupt_routine rb0_int .
What can i make in case of this?
I hope jou give me a answer.
Thanks wolfgang
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
rb0_int
Hallo Steve
My new replay Posted: Wed Sep 26, 2007 12:16 pm
show a new problem with the int on rb0_int.
In mycode i kill all Komponent-Makro "Sample_ADC(0)"
and the programm works ok.I put in a op_amp in, it works also ok,
but i think it is no a solution.I hop you can help.
Regards wolfgang
My new replay Posted: Wed Sep 26, 2007 12:16 pm
show a new problem with the int on rb0_int.
In mycode i kill all Komponent-Makro "Sample_ADC(0)"
and the programm works ok.I put in a op_amp in, it works also ok,
but i think it is no a solution.I hop you can help.
Regards wolfgang
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello Wolfgang
Please can you send me your new code. I will see why the ADC is not working.
Please can you send me your new code. I will see why the ADC is not working.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
rb0_int
Hallo Benj
Ok i send the new code.
but the acd(0) is working ; the problem is,
without a int on portb0 the program go into
the int_macro each time .after i delete the
macro SampleADC the int is working ok.
It is the same efekt as i work with portb......
Regards wolfgang
Ok i send the new code.
but the acd(0) is working ; the problem is,
without a int on portb0 the program go into
the int_macro each time .after i delete the
macro SampleADC the int is working ok.
It is the same efekt as i work with portb......
Regards wolfgang
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
rb0_int
Hallo Benj
I hope you have received my new mail at 02.10.2007.
I have build a small c-code for acd[0]sample and read back
with the acd(0)byte macro,
three lines into my orginal code with rbo_int.All it works correctly ,
so i think there is a fault in the macro.
In expectation for a answer
Regards wolfgang
I hope you have received my new mail at 02.10.2007.
I have build a small c-code for acd[0]sample and read back
with the acd(0)byte macro,
three lines into my orginal code with rbo_int.All it works correctly ,
so i think there is a fault in the macro.
In expectation for a answer
Regards wolfgang
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello Wolfgang
Sorry for the delay.
I think I have found the cause of your problem. The ADC Sample routine converts all of the ADC pins to analogue. The interrupt pin B0 is included in this so it stops functioning as a digital input. You can change this in your FCD file for your PICmicro by opening the 18F4620.FCD file and changing the following line.
to this
The difference being
is changed to
if you are still having problems then try adding a C code icon to the main loop of your program with the following code.
After doing this edit you will not be able to take analogue readings from pin AN12 RB0.
Sorry for the delay.
I think I have found the cause of your problem. The ADC Sample routine converts all of the ADC pins to analogue. The interrupt pin B0 is included in this so it stops functioning as a digital input. You can change this in your FCD file for your PICmicro by opening the 18F4620.FCD file and changing the following line.
Code: Select all
ADCCapture="char ta, tb, te, cnt;\nadcon1 = 0x00;\nadcon2 = 0x03;\nta = trisa;\ntb = trisb;\nte = trise;\n#if (%a == 0)\n trisa = trisa | 0x01;\n#endif\n#if (%a == 1)\n trisa = trisa | 0x02;\n#endif\n#if (%a == 2)\n trisa = trisa | 0x04;\n#endif\n#if (%a == 3)\n trisa = trisa | 0x08;\n#endif\n#if (%a == 4)\n trisa = trisa | 0x20;\n#endif\n#if (%a == 5)\n trise = trise | 0x01;\n#endif\n#if (%a == 6)\n trise = trise | 0x02;\n#endif\n#if (%a == 7)\n trise = trise | 0x04;\n#endif\n#if (%a == 8)\n trisb = trisb | 0x04;\n#endif\n#if (%a == 9)\n trisb = trisb | 0x08;\n#endif\n#if (%a == 10)\n trisb = trisb | 0x02;\n#endif\n#if (%a == 11)\n trisb = trisb | 0x10;\n#endif\n#if (%a == 12)\n trisb = trisb | 0x01;\n#endif\nadcon0 = 0x01 | (%a << 2);\ncnt =0;\nwhile (cnt <40) cnt++;\nadcon0 = adcon0 | 0x02;\nwhile (adcon0 & 0x02) ;\ntrisa = ta;\ntrisb = tb;\ntrise = te;\nadcon1 = 0x0f;\nadcon0 = 0x00;\n"
Code: Select all
ADCCapture="char ta, tb, te, cnt;\nadcon1 = 0x03;\nadcon2 = 0x03;\nta = trisa;\ntb = trisb;\nte = trise;\n#if (%a == 0)\n trisa = trisa | 0x01;\n#endif\n#if (%a == 1)\n trisa = trisa | 0x02;\n#endif\n#if (%a == 2)\n trisa = trisa | 0x04;\n#endif\n#if (%a == 3)\n trisa = trisa | 0x08;\n#endif\n#if (%a == 4)\n trisa = trisa | 0x20;\n#endif\n#if (%a == 5)\n trise = trise | 0x01;\n#endif\n#if (%a == 6)\n trise = trise | 0x02;\n#endif\n#if (%a == 7)\n trise = trise | 0x04;\n#endif\n#if (%a == 8)\n trisb = trisb | 0x04;\n#endif\n#if (%a == 9)\n trisb = trisb | 0x08;\n#endif\n#if (%a == 10)\n trisb = trisb | 0x02;\n#endif\n#if (%a == 11)\n trisb = trisb | 0x10;\n#endif\n#if (%a == 12)\n trisb = trisb | 0x01;\n#endif\nadcon0 = 0x01 | (%a << 2);\ncnt =0;\nwhile (cnt <40) cnt++;\nadcon0 = adcon0 | 0x02;\nwhile (adcon0 & 0x02) ;\ntrisa = ta;\ntrisb = tb;\ntrise = te;\nadcon1 = 0x0f;\nadcon0 = 0x00;\n"
Code: Select all
adcon1 = 0x00; //All AN Pins converted to analogue
Code: Select all
adcon1 = 0x03; //All AN Pins converted to analogue except RB0
Code: Select all
trisb = trisb | 0x01;
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
rb0_int
Hallo Benj
100 points!! After i change the line it works ok.Thanks
Think i right,if i work with the ather int_pin on rb.... i must do
the same ( with other value adcon1)
Is this also the point for the thame effekt ,if i work with the
out macro on portb1 to portb3?
Regards wolfgang
100 points!! After i change the line it works ok.Thanks
Think i right,if i work with the ather int_pin on rb.... i must do
the same ( with other value adcon1)
Is this also the point for the thame effekt ,if i work with the
out macro on portb1 to portb3?
Regards wolfgang
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Hello Wolfgang
if you want to use the INT1 and INT2 on RB1 and RB2 respectively then you can change the line in the FCD file to this.
This will disable the analogue input channels AN8 through to AN12.
The change in this case is
Using an output will be alright as outputs are unaffected by the state of the analogue / digital changes.
if you want to use the INT1 and INT2 on RB1 and RB2 respectively then you can change the line in the FCD file to this.
Code: Select all
ADCCapture="char ta, tb, te, cnt;\nadcon1 = 0x07;\nadcon2 = 0x03;\nta = trisa;\ntb = trisb;\nte = trise;\n#if (%a == 0)\n trisa = trisa | 0x01;\n#endif\n#if (%a == 1)\n trisa = trisa | 0x02;\n#endif\n#if (%a == 2)\n trisa = trisa | 0x04;\n#endif\n#if (%a == 3)\n trisa = trisa | 0x08;\n#endif\n#if (%a == 4)\n trisa = trisa | 0x20;\n#endif\n#if (%a == 5)\n trise = trise | 0x01;\n#endif\n#if (%a == 6)\n trise = trise | 0x02;\n#endif\n#if (%a == 7)\n trise = trise | 0x04;\n#endif\n#if (%a == 8)\n trisb = trisb | 0x04;\n#endif\n#if (%a == 9)\n trisb = trisb | 0x08;\n#endif\n#if (%a == 10)\n trisb = trisb | 0x02;\n#endif\n#if (%a == 11)\n trisb = trisb | 0x10;\n#endif\n#if (%a == 12)\n trisb = trisb | 0x01;\n#endif\nadcon0 = 0x01 | (%a << 2);\ncnt =0;\nwhile (cnt <40) cnt++;\nadcon0 = adcon0 | 0x02;\nwhile (adcon0 & 0x02) ;\ntrisa = ta;\ntrisb = tb;\ntrise = te;\nadcon1 = 0x0f;\nadcon0 = 0x00;\n"
The change in this case is
Code: Select all
adcon1 = 0x07; //Enable AN0 - AN7 as analogue inputs
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Yes this fix would do the following job.
Sampling an ADC channel would convert that particular channel and all other channels beneath it to analogue.
For example sampling AN8 would convert AN0 - AN8 to analogue. This means that the higher end channels are still available.
One word of caution when using this is if you were sampling AN9 then AN8 which is connected to INT2 would also be converted to analogue which would disable the interrupt while the sampling process is taking place.
Sampling an ADC channel would convert that particular channel and all other channels beneath it to analogue.
For example sampling AN8 would convert AN0 - AN8 to analogue. This means that the higher end channels are still available.
One word of caution when using this is if you were sampling AN9 then AN8 which is connected to INT2 would also be converted to analogue which would disable the interrupt while the sampling process is taking place.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel