|
|
View previous topic :: View next topic |
Author |
Message |
scanan
Joined: 13 Aug 2004 Posts: 58 Location: Turkey
|
about pic16f18345 |
Posted: Fri Apr 07, 2017 6:37 am |
|
|
hey all,
I am trying to do some input function with pic16f18345.
Everything work fine with the PORTA with pinA0 pinA1 pinA2 pinA3 and pinA5.
When it comes to pinA5 I can't get input from this pin.
my code is as below
Code: |
void main() {
SET_TRIS_A( 0xFF );
SET_TRIS_B( 0x00 );
SET_TRIS_C( 0xF7 );
loop:
//if( IOpinIN.rotatelightsw)
if(input(PIN_A5))
{
ouptput(pin_B1);
}
}
|
any comment will be appreciated
cheers _________________ Dr Suleyman CANAN
R&D Electronic Engineer
https://suleymancanan.wordpress.com
Do whatever you do with amateur spirit -
But always feel professional.
Last edited by scanan on Fri Apr 07, 2017 7:46 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Apr 07, 2017 6:53 am |
|
|
quick answer
1st you should always post a complete test program as it could be a 'fuses' problem maybe even compiler version....
That pin, RA5, has several peripherals attached to it, so you should disable all of them, ADC, clock, timer, etc. whatever is attached....
Jay |
|
|
scanan
Joined: 13 Aug 2004 Posts: 58 Location: Turkey
|
|
Posted: Fri Apr 07, 2017 7:09 am |
|
|
here with extras
CCS ver. 5.062
Code: |
#include <16f18345.h>
/////////////////////////////////FUSES/////////////////////////////////////////
#use delay(internal=32M)
#FUSES RSTOSC_HFINTRC_PLL
#Fuses PUT ,NOWDT,NOLPBOR,NOBROWNOUT,PROTECT
#Fuses NOCLKOUT,NOCKS,NOFCMEN,NOMCLR
#Fuses NOPPS1WAY,PPS1WAY,NOSTVREN,STVREN,DEBUG,NODEBUG,WRT,WRT_400
void main() {
SET_TRIS_A( 0xFF );
SET_TRIS_B( 0x00 );
SET_TRIS_C( 0xF7 );
loop:
//if( IOpinIN.rotatelightsw)
if(input(PIN_A5))
{
ouptput(pin_B1);
}
} |
_________________ Dr Suleyman CANAN
R&D Electronic Engineer
https://suleymancanan.wordpress.com
Do whatever you do with amateur spirit -
But always feel professional. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Fri Apr 07, 2017 10:45 am |
|
|
You have a whole suite of fuses, where you are telling the compiler both to set them, and clear them. For instance:
NOPPS1WAY,PPS1WAY
This says 'turn off PPS1WAY', and 'turn on PPS1WAY'.
Which it'll actually use is a guess (probably the last).
Fuses need to only be set one way or the other, not both....
As written the code will drop off the end, and go to sleep.
You are then trying to output to the pin with a function called 'ouptput', and not saying 'what' you want to output to the pin.
Then the chip doesn't have a pin 'B1'....
Port B pins start at B4 on this chip.
I doubt if the code would compile.
Once these are fixed, I'd suspect Temtronic is on the right lines with a peripheral needing to be disabled. Pin A5 is the default clock input for some things.
It also will not run without a debugger as posted. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|