Hi. I make a program with flowcode 2.0 and in simulation mode it work very well, but is not the same in my circuit. The program is an analog imput (GPO) that is all time reading it and a push botton, when i push a push botton (GP3) it stop reading and put 1 in GP1 for 2 second and 0 after this time, wirite the analog value in eeprom and then return to reading. The problem is the following. When it is reading the analog imput (GP0), the output (GP1) is flashing (i see a high frecuency square signal in my ossciloscope), and when i push the botton, the output (GP1) IS ok. If i delete the ADC macro, there are no problem. What is the problem in my program?
Thank
Problem with PIC12F675
- 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:
Re: Problem with PIC12F675
Hello Ramtec
Flowcode V3 has been out for over a year and a half now and so we can no longer provide support for Flowcode V2.
The problem with the program is that when an Analogue channel is being sampled, all of the analogue channels are converted to analogue inputs. This will inevitably disable the current output on your I/O pins.
I can confirm that this problem has been fixed in the latest release of Flowcode V3.
This may help to solve the problem, Open the 12F675.fcd file from your Flowcode directory,
Find the following line.
Change it to this
Due to other bug fixes along the way this fix may not work for Flowcode V2.
Flowcode V3 has been out for over a year and a half now and so we can no longer provide support for Flowcode V2.
The problem with the program is that when an Analogue channel is being sampled, all of the analogue channels are converted to analogue inputs. This will inevitably disable the current output on your I/O pins.
I can confirm that this problem has been fixed in the latest release of Flowcode V3.
This may help to solve the problem, Open the 12F675.fcd file from your Flowcode directory,
Find the following line.
Code: Select all
ADCCapture="char ta, cnt;\nansel = 0x27;\nta = trisio;\ntrisio = trisio | 0x17;\nadcon0 = 0x01 | (%a << 2);\ncnt =0;\nwhile (cnt <220) cnt++;\nadcon0 = adcon0 | 0x02;\nwhile (adcon0 & 0x02) ;\ntrisio = ta;\nansel = 0x20;\n"
Code: Select all
ADCCapture="//set up ADC conversion\nchar old_tris, cnt;\n#define MX_ADC_SAMP_TIME 40\n#define MX_ADC_TRIS_REG trisio\n\n//find appropriate bit\n#if (%a == 0)\n #define MX_ADC_TRIS_MSK 0x01\n #define MX_ADC_ANS_MSK 0x01\n#endif\n#if (%a == 1)\n #define MX_ADC_TRIS_MSK 0x02\n #define MX_ADC_ANS_MSK 0x02\n#endif\n#if (%a == 2)\n #define MX_ADC_TRIS_MSK 0x04\n #define MX_ADC_ANS_MSK 0x04\n#endif\n#if (%a == 3)\n #define MX_ADC_TRIS_MSK 0x10\n #define MX_ADC_ANS_MSK 0x08\n#endif\n\n//sanity check\n#ifndef MX_ADC_TRIS_MSK\n #pragma error ADC conversion code error - please contact technical support\n#endif\n\n//store old tris value, and set the i/o pin as an input\nold_tris = MX_ADC_TRIS_REG;\nMX_ADC_TRIS_REG = MX_ADC_TRIS_REG | MX_ADC_TRIS_MSK;\nansel = 0x20 | MX_ADC_ANS_MSK;\n\n//turn ADC on\nadcon0 = 0x01 | (%a << 2);\n\n//wait the acquisition time\ncnt =0;\nwhile (cnt <40) cnt++;\n\n//begin conversion and wait until it has finished\nadcon0 = adcon0 | 0x02;\nwhile (adcon0 & 0x02) ;\n\n//restore old tris value, and reset adc registers\ntrisio = old_tris;\nansel = 0x20;\nadcon0 = 0x00;\n#undef MX_ADC_TRIS_REG\n#undef MX_ADC_TRIS_MSK\n#undef MX_ADC_SAMP_TIME\n#undef MX_ADC_ANS_MSK\n"
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