View previous topic :: View next topic |
Author |
Message |
AlastairM
Joined: 28 Apr 2008 Posts: 28
|
dsPIC33 weak pull downs for info! |
Posted: Mon Apr 08, 2013 5:14 pm |
|
|
(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: 19540
|
|
Posted: Tue Apr 09, 2013 12:58 am |
|
|
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
|
|
Posted: Tue Apr 09, 2013 3:36 am |
|
|
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: 19540
|
|
Posted: Tue Apr 09, 2013 4:07 am |
|
|
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
|
|
Posted: Tue Apr 09, 2013 4:27 am |
|
|
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: 19540
|
|
Posted: Tue Apr 09, 2013 4:53 am |
|
|
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 |
|
|
|