I'm pretty sure this is due to the serial feature on C.7.
I have LEDs on all port C pins and pin 7 lights the LED with TRISC = %11111111
Is C.7 pulled high waiting for an external serial data stream to pull it low?
RCSTA? TXSTA?
Neo
I'm pretty sure this is due to the serial feature on C.7.
I have LEDs on all port C pins and pin 7 lights the LED with TRISC = %11111111
Is C.7 pulled high waiting for an external serial data stream to pull it low?
RCSTA? TXSTA?
Neo
For starters; 1 means input, 0 is output.
Posting all your code wouldn't hurt either.
Robert
Example:
http://www.picbasic.co.uk/forum/show...ht=tris+output
Last edited by Demon; - 31st March 2013 at 12:52. Reason: search results
Sorry, I guess I wasn't very clear. I'm just playing around with ADCs on PortA, not doing anything with PortC. I'm using a EasyPIC3 development board so LEDs are available on all pins. I'm aware the 1 means input and that as an input the pin may float above 0V but I was under the impression that it should not have enough power to drive an LED when set as an input. None of the other pins on PortC drive the LEDs but C.7 is bright. Using melabs U2 Programmer to program the MCU; set MCU to 16F887, Oscillator to XT, all other fuses to default. LCD, ADCs work as expected, just this C.7 thing is odd and just do to my ignorance.
Code:' Define LCD pins DEFINE LCD_DREG PORTB ' Sets LCD Data Port to Port-B instead of default Port A DEFINE LCD_DBIT 4 ' Sets for use of PortB bits 4 thru 7 for the data DEFINE LCD_RSREG PORTB ' Sets RS (Register Select) to Port B instead of default PortA.4 DEFINE LCD_RSBIT 2 ' Sets RS (Register Select) to bit 2 of port B (PORTB.2) ' ' Enable stays at the default PORTB.3 ANSELH = 0 ANSEL = 0 ' This sets the ADCs to Digital Low PORTB.2 ' LCD R/W line low (W) Pause 2000 ' Wait 2 seconds (2000 mS)for LCD to start Lcdout $fe, 1, "16F887 ADC Test" ' Display sign-on message TRISC = %1111111 DEFINE ADC_BITS 10 ' 10 bit A/D Conversion ANSELH = 0 ANSEL = %00001100 ' Set pin (AN2, AN3) to analog input, the rest to digital ADCON1 = %10000000 ' Set up A/D converter - Right Just., VDD REF. adc_val var word adc_val_2 var word pause 2000 'settle mainloop: ADCIN 2, adc_val ' Get ADC value from ADC channel 2 ADCIN 3, adc_val_2 ' Get ADC value from ADC channel 3 Lcdout $fe, 1, DEC (adc_val)," ADC 1 Value" Lcdout $fe, $C0, DEC (adc_val_2)," ADC 2 Value" Pause 200 goto mainloop End
Last edited by Neosec; - 31st March 2013 at 13:59.
Just some more input...
On the 16F887 PORTC.6 and PORTC.7 have a ENHANCED UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER TRANSMITTER (EUSART) feature. C.6 is labeled RC6/TX/CK and C.7 is RC7/RX/DT. I have to assume that, since I've set C.7 as in input and there's no data going out the DT line, that the RX (receiver) is holding the pin high. So, I guess my question is about the basics of the serial data feature on the MCU and why it affects this pin the way it does?
TIA
Tried setting RCSTA: RECEIVE STATUS AND CONTROL REGISTER to RCSTA = %00000000
In an attempt to disable the serial port but it had no effect. C7 still high. BTW there is a 10k pull down resistor enabled on the dev. board (all of port C) and the output of C.7 is over-driving it.From Data Sheet -
bit 7 SPEN: Serial Port Enable bit
1= Serial port enabled (configures RX/DT and TX/CK pins as serial port pins)
0= Serial port disabled (held in Reset)
Edit: And just FYI, If I set C.7 as an output and PORTC.7 = 0 the LED goes out (off) as it should.
Last edited by Neosec; - 31st March 2013 at 15:22.
Try adding another 1 to your TRIS statement. It only has 7.
TRISC = %1111111
is the same as ...
TRISC = %01111111
Which puts PORTC.7 in output mode.
Or just leave the TRIS statement out. PIC's default to all 1's for all TRIS registers.
DT
Bookmarks