CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

dsPIC33 weak pull downs for info!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
AlastairM



Joined: 28 Apr 2008
Posts: 28

View user's profile Send private message

dsPIC33 weak pull downs for info!
PostPosted: Mon Apr 08, 2013 5:14 pm     Reply with quote

(see later posts for correct usage of set_pulldown)
Hi.
I'm using dsPIC33EP64MC504 / PCD 4.141
I eventually got weak pull downs working on an individual basis by
Code:
set_pulldown(PIN_B6);

thought I'd share that since I couldn't find it in the manuals or header files!
regards
Al


Last edited by AlastairM on Tue Apr 09, 2013 3:39 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue Apr 09, 2013 12:58 am     Reply with quote

In the manual.....
"
Syntax: set_Pulldown(state [, pin])

Parameters: Pins are defined in the devices .h file. If no pin is provided in the function call, then all of the pins are set to the passed in state.

State is either true or false.
"

So syntax should be:
Code:

set_pulldown(TRUE,PIN_B6);


If you look at the assembler, this correctly sets the pulldown on the one pin.
The code you post, doesn't. It sets bits in all the registers:
Code:

.................... set_pulldown(TRUE,PIN_B6);
0222:  BSET.B  E1C.6  //sets one pulldown bit
.................... set_pulldown(PIN_B6);
0224:  MOV     #8F6A,W4
0226:  MOV     W4,E0C
0228:  MOV     #8F6A,W4
022A:  MOV     W4,E1C
022C:  MOV     #8F6A,W4
022E:  MOV     W4,E2C
//sets bits in all three pulldown registers....

It is treating 'PIN_B6', as the number 28822 two's complemented, (0x8F6A), and putting this pattern into all three pulldown registers.....
It is not setting the individual bit as you want.....

Best Wishes
AlastairM



Joined: 28 Apr 2008
Posts: 28

View user's profile Send private message

PostPosted: Tue Apr 09, 2013 3:36 am     Reply with quote

oops! You are correct...
I tried my version and it worked for B5 and B6 (by a fluke!) I then tried to simulate it to look at the registers but the simulation crashed everytime. I should have looked at the disassembly!
Which manual are you looking at? I have PCD June 2012 which doesn't mention set_pulldown
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue Apr 09, 2013 4:07 am     Reply with quote

The current one included with the compiler.
This often lags the pdf one, but was updated quite recently, and now leads the pdf one....
The syntax is identical to 'set_pullup', which is in your manual.

Best Wishes
AlastairM



Joined: 28 Apr 2008
Posts: 28

View user's profile Send private message

PostPosted: Tue Apr 09, 2013 4:27 am     Reply with quote

It all becomes clear at last!
I use MPLAB as my IDE and the help button on the menu bar doesn't launch the PCD help file when a PCD is the current device. I now know why I've been struggling!
Do you use the CCS IDE (I had bad experiences in the past and haven't revisited it) or the MPLAB 8 IDE?
Thanks for your help debugging...
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue Apr 09, 2013 4:53 am     Reply with quote

Both, and others (ICE).

Remember you can always open the current working manual by just clicking on the .chm file. Have this up alongside whatever else you are using, and you don't have to worry about how which manual it uses!....

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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