View previous topic :: View next topic |
Author |
Message |
pk178
Joined: 10 Mar 2010 Posts: 10
|
Help me with dsPIC |
Posted: Tue Jul 13, 2010 6:23 am |
|
|
Hi everybody !
I'm new in dsPIC, I wrote a program, very simple, this is my code :
Code: | #include <30F2020.h>
#device *=16
#FUSES NOPROTECT, NOWDT, FRC
#use fast_io(d)
void main(){
set_tris_d(0);
setup_oscillator(OSC_RC);
output_d(0);
while(1);
} |
I want set port D at low logic, but I when I tested, logic level of port is not high, I don't know where is problem, please help me, thank a lot ! |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Wed Jul 14, 2010 11:35 am |
|
|
Where's the code for the function output_d(0);??
Post your full code (if it's short) or a test program (which that seems to not be) with your compiler version.
I think you need a #use delay (clock=<freq>) declaration.
Also, I think the setup_oscillator is redundant since you have a #FUSE to set the INTRC
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
pmuldoon
Joined: 26 Sep 2003 Posts: 218 Location: Northern Indiana
|
|
Posted: Thu Jul 15, 2010 12:21 pm |
|
|
What I see is:
Set all Port D pins to outputs;
Clear all Port D pins (logic low);
Wait forever;
And you say that you set port D low and when testing the port it is not high.
I don't see the problem. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Jul 15, 2010 12:25 pm |
|
|
pmuldoon wrote: | What I see is:
Set all Port D pins to outputs;
Clear all Port D pins (logic low);
Wait forever;
And you say that you set port D low and when testing the port it is not high.
I don't see the problem. |
I don't either. (reviewing that output_d() is a CCS command I never use)...
Your code does exactly what you describe.
PORT D (all of it) has been set to 0.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|