View previous topic :: View next topic |
Author |
Message |
J_GROUP
Joined: 25 Aug 2015 Posts: 18
|
Disable analog 18F26k22 |
Posted: Tue Mar 01, 2016 9:03 am |
|
|
Hi
I need disable analog input mode on pin RC7 of 18F26k22. Please help |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Tue Mar 01, 2016 9:11 am |
|
|
You should post a small program so we can see what you're doing. As that pin is also used for 3 other peripherals it is possible.
Jay |
|
|
J_GROUP
Joined: 25 Aug 2015 Posts: 18
|
|
Posted: Tue Mar 01, 2016 9:36 am |
|
|
Code: | #include <18f26k22.h>
#device *=16
#include <math.h>
#include <float.h>
#include <stdio.h>
#include <brands_select.h>
#fuses WDT8192,PROTECT,NOLVP,MCLR,NOBROWNOUT,NOXINST
#fuses HSM,PLLEN
#use delay(clock=32000000,crystal=8000000, RESTART_WDT)
#USE RS232 (UART1, BAUD = 9600, XMIT = PIN_C6, RCV = PIN_C7,bits=8) //RS-232 parametres
#int_RDA
void rda_interrupt()
{
#USE RS232 (UART1)
st=getc();
str_check[ic]=st;
ic=ic+1;
output_high(Signal_led);
if (ic>84) {ic=1; str_check[0]=str_check[84]; }
} |
|
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Mar 01, 2016 10:32 am |
|
|
Hi,
What compiler version are you running? You shouldn't have to explicitly 'turn off' analog input mode on C7 once you've setup the hardware UART. You should also post a complete, compilable program for us to look at. Your program is very incomplete, lacking a Main(), and numerous variable declarations.
Are you sure your PIC is running? Is it running at the intended speed? Have you done the classic 'LED flash' test? _________________ John
If it's worth doing, it's worth doing in real hardware!
Last edited by ezflyr on Tue Mar 01, 2016 11:08 am; edited 1 time in total |
|
|
J_GROUP
Joined: 25 Aug 2015 Posts: 18
|
|
Posted: Tue Mar 01, 2016 10:42 am |
|
|
sir,
this program and hardware I was running on 18F25k22. This time I need more memory so I change to 18F26k22 and get trouble |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Tue Mar 01, 2016 10:54 am |
|
|
John's right, again..
we NEED a small, complete, compilable program to help further.
What you've shown already has several coding errors
including but not limitied to
protect fuse enabled
lack of errors option in use rs232(...)
wdt set to restart
incomplete list of fuses
include of brands_select.h 'header', unknown to us, NOT CCS supplied
I use the 'big brother 18F46K22' as my main PIC and have no problems using RC7 for other uses.
jay |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1349
|
|
Posted: Tue Mar 01, 2016 11:51 am |
|
|
You also have
inside the ISR, which is meaningless and could be your problem if the default values for the two chips differ.
#use rs232() is not run time code. It is a precompiled directive. It should not be inside of a function. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Tue Mar 01, 2016 2:23 pm |
|
|
and the fuses, clock statement, and RS232 declarations, should always be _before_ the other includes. Otherwise anything in these using RS232, or delays, may well not function.... |
|
|
|