|
|
View previous topic :: View next topic |
Author |
Message |
hello188
Joined: 02 Jun 2010 Posts: 74
|
Broken Output port Pin? |
Posted: Tue Apr 26, 2011 8:08 pm |
|
|
Hi, currently, I am working with PIC18Fk46k22, and checking the output functionality.
To PORTD0~PORTD.5, a solenoid relay is connected via opto-coupler with separate ground, so the MCU is electrically isolated from the back EMF from inductor.
To check, I simply set port direction to outputs and output 0x00 to the PORTD, to turn on the LED and solenoid.
I am working with two identically constructed target board, and looking at PORTD register with ICD3 debugger.
The strange thing I discovered is that depending on the target board, WITH SAME PROGRAM, certain bits(higher bits, which are 7, 6, 5,4) can not stay 0, and instead gets pulled back up to 1.
Below is my code
Code: |
//SETUP
#INCLUDE<18F46K22.h>
#INCLUDE<def_18f46K22.h>
#FUSES HSH, NOPLLEN, NOIESO, PUT, NOBROWNOUT, NOWDT, NOPBADEN, MCLR, STVREN
void main(void){
TRISD = 0x00;
PORTD = 0x00
while(1);
}
|
As I look at the registers on the WATCH window, TRISD remains 0x00 but PORTD reads 0b00010000 or 0b00110000 depending on the target board.
I am thinking the two pins(PORTD.5, and PORTD.6) got somehow damaged? I think that the condition is affecting the SFRs too since ICD3 is reading from them.
Anyone has experienced this??
Thank you |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 26, 2011 8:40 pm |
|
|
Post your compiler version. |
|
|
hello188
Joined: 02 Jun 2010 Posts: 74
|
|
Posted: Tue Apr 26, 2011 9:51 pm |
|
|
It's 4.120 The latest
When I run it with simulator instead of ICD3, the port behaves fine.
Thank you |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 26, 2011 10:35 pm |
|
|
What do you see if you look at the pins with an oscilloscope ?
Also, describe your oscillator circuit. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Apr 27, 2011 12:39 am |
|
|
What's the IO load current? Source or sink? |
|
|
hello188
Joined: 02 Jun 2010 Posts: 74
|
|
Posted: Wed Apr 27, 2011 5:19 pm |
|
|
On the oscilloscope, the voltage is Vcc.
The sink currents should be less than 10 mAs |
|
|
|
|
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
|