Hello Martin,
I ask you for help with an operation that I don't know how to perform.
I am using the PIC12f1840 because I need few I / O and a serial line. The program starts with an initial setting of pins 6 and 7 such as RX and TX and after acquiring some data from a PC (via rs232) I need to set (at this point in the program) these 2 ports as analog inputs (the hardware is ready to do so).
To set the various functions of the chip I use the "2D: Dashboard Panel" and I don't think I can set the functions of pins 7 and 8 both for the rs232 and as analog inputs whose functions I would then call in the program after having finished the work with the rs232.
I would be very grateful if you could give me a suggestion (assuming that what I need it can be done)
Regards
castabob
Pic12F1840 how to change settings durin it run
Moderator: Benj
- 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: Pic12F1840 how to change settings durin it run
Hello,
If you call the following code in a C icon after you are finished with the UART then this should disable the UART and put the pins back into the standard IO mode where you can use them as ADC inputs or general purpose IO.
If you want the UART functionality again after this simply call the initialise function again.
If you call the following code in a C icon after you are finished with the UART then this should disable the UART and put the pins back into the standard IO mode where you can use them as ADC inputs or general purpose IO.
Code: Select all
TXSTA = 0;
RCSTA = 0;
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
Re: Pic12F1840 how to change settings durin it run
Hi,
sorry if I haven't answered before but I had to fix other little things to run the program correctly. After the indication you gave me, everything is working properly now.
I have another problem where the compiler gives me an error (attached file) . Where am I wrong? How can I solve it?
Yours sincerely
castabob
sorry if I haven't answered before but I had to fix other little things to run the program correctly. After the indication you gave me, everything is working properly now.
I have another problem where the compiler gives me an error (attached file) . Where am I wrong? How can I solve it?
Yours sincerely
castabob
- Attachments
-
- Error.pdf
- (47.85 KiB) Downloaded 211 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Pic12F1840 how to change settings durin it run
Hi Bob,
Can you try
Alternatively you can just have an output and set it to 1 or 0 at the required time.
Can you try
Code: Select all
TRISAbits.TRISA5 = 0;
Martin
Re: Pic12F1840 how to change settings durin it run
Hi,
as you suggest to me "TRISAbits.TRISA5 = 0;" the compilation do not give error.
Before I had tried only writting the instruction: "TRISA5 = 0;" and even so it didn't give me an error ... is it correct even just so?
thank you very much
Regards
bob
as you suggest to me "TRISAbits.TRISA5 = 0;" the compilation do not give error.
Before I had tried only writting the instruction: "TRISA5 = 0;" and even so it didn't give me an error ... is it correct even just so?
thank you very much
Regards
bob
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Pic12F1840 how to change settings durin it run
Hi Bob,
your're welcome.
what I would do is after, is just confirm by connecting a 1Kto 10K resistor from the A5 pin to VDD.
If voltage is 0V then it's worked.
If around VDD, then has not worked.
I believe it will work and should not be an issue.
your're welcome.
That should work equally well.castabob wrote:Before I had tried only writting the instruction: "TRISA5 = 0;" and even so it didn't give me an error ... is it correct even just so?
what I would do is after
Code: Select all
TRISA5 = 0;
If voltage is 0V then it's worked.
If around VDD, then has not worked.
I believe it will work and should not be an issue.
Martin