|
|
View previous topic :: View next topic |
Author |
Message |
lifespeed
Joined: 17 Aug 2005 Posts: 19
|
disable pullup on SPI 3-wire input (SDI) line? |
Posted: Wed Sep 07, 2005 11:34 am |
|
|
I'm trying to use the SPI port in three wire mode, but it seems to be applying a pullup to the input (labeled SDI/RC4 on the 18F8722). This is causing difficulty, as I must accept this signal through a resistive divider from a 3.3V part. Hardware is already layed out, it's a bit late to apply a hardware fix, which I'm not sure should be necessary anyway.
I notice in the I2C library there is a command "PULLHIGH_OFF" or something to that effect. It seems this feature is accessible somewhere in the hardware. What can I do to turn of this pullup while using the SPI three-wire input? _________________ Lifespeed |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 07, 2005 2:27 pm |
|
|
Quote: | I'm trying to use the SPI port in three wire mode, but it seems to be applying a pullup to the input (labeled SDI/RC4 on the 18F8722).
|
There are no programmable pull-up resistors on Port C. They are
only available on Port B.
Quote: | I notice in the I2C library there is a command "PULLHIGH_OFF" or something to that effect. |
The i2c library code is not used for SPI. Also, there is no "#use spi()"
statement in CCS. For hardware SPI, you can use the setup_spi(),
spi_write(), spi_read(), etc., functions. Also, you can do software
SPI if you wish (but you must write the code for it).
If you see the SDI pin is being pulled up, then it could mean:
1. Your circuit is wired incorrectly.
2. Somehow, you have inserted code which turns the SDI pin
into an output pin, and set it high.
3. The CCS spi functions may not be correct for your version of
the compiler. Post the version that you're using.
4. Also, are you possibly trying to use hardware SPI and i2c on the
same pins (C3 and C4) ? If so, don't do that. |
|
|
Ttelmah Guest
|
|
Posted: Wed Sep 07, 2005 2:30 pm |
|
|
Basically on the PIC, Inputs, don't have pull-ups, except for specific pins with this ability (normally portB). In I2C, an input pullup, is _simulated_ by changing the input pin to be an output, and driving this high, when using software I2C. The SPI input pin, does not have a pull-up present, and in SPI mode cannot be driven this way. Driving a SPI input from a 3.3v part, will have problems, not because a pull-up is present, but because it is _missing_. The 3.3v part will only pull the line up to 3.3v max, but the SDI pin requires to be driven to 0.8* the PIC's supply voltage (4v if the PIC is running off 5v). Trying to drive this sort of input, with a resistive divider, will not work. It _might_ in some cases be possible to drive such an input by using a pull-up, and a diode, so the 3.3v output only pulls the signal downwards, and the pull-up then (just) pulls the signal high enough, but on a schmitt trigger input, the voltages are borderline for doing this. I'm afraid that if you board is laid out, some bodging is going to be needed. This should have been sorted and tested before committing to a board...
Best Wishes |
|
|
lifespeed
Joined: 17 Aug 2005 Posts: 19
|
|
Posted: Wed Sep 07, 2005 3:26 pm |
|
|
I should mention we are using the current version (released two weeks ago) of CCS compiler. I should also mention we are using the ICE 2000 emulator, I would hope emulating port behavior is accurate, but I shouldn't assume this.
Lastly, the 3.3V logic issue is not really that important, I'm only reading back from a chip I don't really need to read from.
Here is the issue: When the second SPI port is operating as slave, driven by 5V logic thru a 10K series resistor, a pullup of the size that I have seen (approx. 10K, again, using the emulator) will divide down the signal so as to not properly send data to the PIC.
I read that there is no pullup when configured as an input, however I am clearly seeing this electrically.
Here is the setup for SPI:
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_timer_4(T4_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
set_tris_a(0x00); // RA0-RA7 are outputs
set_tris_f(0x00); // so are RF0-RF7
set_tris_h(0x00); // so are RF0-RF7
set_tris_c(0x10); // RC4 is an input
setup_spi(SPI_MASTER | SPI_CLK_DIV_16 | SPI_XMIT_L_TO_H | SPI_L_TO_H);
From here, all I use is spi_read and spi_write. I have used bit-banging routines with similar results. _________________ Lifespeed |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 07, 2005 3:47 pm |
|
|
I need more information:
1. Is your problem with the SPI1 or SPI2 port ?
In your post, you mention SPI2 but your setup code is only for SPI1.
2. You mentioned a 10K series resistor. That's a very high value for
a series resistor.
Can you describe the complete voltage divider circuit that you
are using on the SDI pin ? Tell the values and the location of
each resistor in the circuit. (Also, is it on SDI1 or SDI2 ?)
3. What is your exact version of the compiler ? |
|
|
lifespeed
Joined: 17 Aug 2005 Posts: 19
|
|
Posted: Wed Sep 07, 2005 4:37 pm |
|
|
Thanks for all the help. Here is what I've found:
CCS ver 3.231
This odd pullup behavior on the SDI (port 0) input is only present when the emulator is connected to the picdemo board. When I do not connect it and just run the emulator and look at the SDI pin (RC4) it behaves normally, and is at 0V steady state. However when I plug the emulator into the PICdemo board, the voltage on SDI/RC4 goes up to 4.9VI notice also that it does not seem to need the PICdemo board to operate, it must have a PIC18F8722 in the module connecting to the ICE2000, or at least something that emulates the PIC18F8722? I suppose that's why it's called an emulator . . . ;)
At this point it appears I have either somehow damaged the picdemo board, or there is some sort of design issue where the PIC chips ports on the demo board are not really tri-stated while the emulator is plugged in. I think that, in theory, the emulator is supposed to be able to plug into the PICdemo and board and take the PIC on the demo board "out of the circuit".
I will try and determine if I have a fried PIC, or if this a design problem, and report my results back here.
Thanks again, _________________ Lifespeed |
|
|
Ttelmah Guest
|
|
Posted: Thu Sep 08, 2005 5:07 am |
|
|
You have presumably configured JP1?.
This is _required_ if you are using the ICE module on the board (forces the processor into a reset state).
Page 50 of the manual.
Best Wishes |
|
|
lifespeed
Joined: 17 Aug 2005 Posts: 19
|
|
Posted: Thu Sep 08, 2005 12:20 pm |
|
|
Ttelmah wrote: | You have presumably configured JP1?.
This is _required_ if you are using the ICE module on the board (forces the processor into a reset state).
Page 50 of the manual.
Best Wishes |
Looking at the schematic, JP1 on the DM183022 demo board just grounds the LEDs. However, I do understand that the processor should be reset. S3 in the schematic, located at
http://ww1.microchip.com/downloads/en/DeviceDoc/DM183022_Rev4_Sch.pdf
shows that MCLR is connected to the ICE 2000 when in the ICE position.
I do believe you are correct that I am having issues related to properly resetting the PIC on the demo board while the emulator is running. When I look at the schematic, I see that the MCLR pin for the emulator is not the same as for the PIC on the demo board.
I will continue my reading, but at this point I am not sure how to get the PIC powered and reset while the emulator is running. There are options to power the PIC from the emulator, or from the DC plug. Also there are options in MPLAB to for the emulator to provide the MCLR pullup. So far, I have tried all combinations without success. Any guidance you can provide would be appreciated. _________________ Lifespeed |
|
|
lifespeed
Joined: 17 Aug 2005 Posts: 19
|
|
Posted: Thu Sep 08, 2005 3:19 pm |
|
|
I'm embarassed to admit this, but in the interest of full disclosure . . .
The PIC demo board had a 7.5K pullup on the SPI input line only (SDA/RC4).
Thanks for your help.
It does like like the 3.3V logic meets the input threshold, from the PIC data sheet, 2V is the max logic high input level.
Now I've just got to get the 64-bit math working, I've got those definable-precision C routines from some guy named Mark, last name escapes me right now. _________________ Lifespeed |
|
|
Ttelmah Guest
|
|
Posted: Thu Sep 08, 2005 4:03 pm |
|
|
They have obviously changed things on revision 4 of the board.
Double check the input threshold. The SDI line has a schmitt trigger input...
Best Wishes |
|
|
lifespeed
Joined: 17 Aug 2005 Posts: 19
|
|
Posted: Fri Sep 09, 2005 10:00 am |
|
|
You are correct on the Schmidt trigger threshold, which is the type of input I would expect to be configured for SPI operation. Perhaps this is a case of emulator vs PIC, or the specification and typical performance are different. I will be trying the PIC on its own today to check this, and I will also verify voltage margin about the logic threshold before communication fails.
Of course it is incorrect to design to typical, vs specified, but the 3.3V logic SPI 3-wire input is only a luxury and an afterthought, the necessary SPI input from the customer is 5V logic guaranteed by specification and design.
Thanks, _________________ Lifespeed |
|
|
|
|
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
|