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

Confused pin on PIC16F1946

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



Joined: 02 Aug 2011
Posts: 10

View user's profile Send private message

Confused pin on PIC16F1946
PostPosted: Thu Aug 18, 2011 1:29 am     Reply with quote

Hi,

I'm using the above micro, the 64pin tqfp package.
Pin 45 is connected to a switch button.
I'm going to have an LCD display but it is not connected at the moment. I'm trying to write the program for reading switches and drive other output at the moment.

That button that is connected to pin 45 (RB3/SEG10) stop working whenever I have this line
Code:

setup_lcd(   LCD_TYPE_B | LCD_MUX13 | LCD_BIAS13 | LCD_REF_ENABLED | LCD_B_HIGH_POWER | LCD_TIMER1,  0, 0x131437);

It works okay without this line. My fuses are
Code:

#device ICD = TRUE

#FUSES WDT                      //Watch Dog Timer
#FUSES LP                       
#FUSES WDT_NOSL                 //Watch Dog Timer, disabled during SLEEP
#FUSES WRT                      //Program Memory Write Protected
#FUSES BORV25                   //Brownout reset at 2.5V
#FUSES NOLVP                    //No low voltage prgming,
#FUSES NOMCLR
#FUSES INTRC_IO
#FUSES PUT

Any idea why?

Many thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 18, 2011 11:40 am     Reply with quote

Quote:
#device ICD = TRUE

#FUSES WDT //Watch Dog Timer
#FUSES LP
#FUSES WDT_NOSL //Watch Dog Timer, disabled during SLEEP
#FUSES WRT //Program Memory Write Protected
#FUSES BORV25 //Brownout reset at 2.5V
#FUSES NOLVP //No low voltage prgming,
#FUSES NOMCLR
#FUSES INTRC_IO
#FUSES PUT

Don't use two oscillator fuses. LP is for a watch crystal (32.768 KHz).
INTRC_IO is the internal oscillator. Delete the LP fuse. Also, don't
enable the WDT in a test program. Delete the WDT fuse.


Quote:

Pin 45 is connected to a switch button.
I'm going to have an LCD display but it is not connected at the moment. I'm trying to write the program for reading switches and drive other output at the moment.

That button that is connected to pin 45 (RB3/SEG10) stop working whenever I have this line

setup_lcd( LCD_TYPE_B | LCD_MUX13 | LCD_BIAS13 | LCD_REF_ENABLED | LCD_B_HIGH_POWER | LCD_TIMER1, 0, 0x131437);

What board are you using ? Post the manufacturer and part number.
juinhooley



Joined: 02 Aug 2011
Posts: 10

View user's profile Send private message

PostPosted: Sun Aug 21, 2011 5:18 pm     Reply with quote

PCM programmer wrote:

#device ICD = TRUE

#FUSES WDT //Watch Dog Timer
#FUSES LP
#FUSES WDT_NOSL //Watch Dog Timer, disabled during SLEEP
#FUSES WRT //Program Memory Write Protected
#FUSES BORV25 //Brownout reset at 2.5V
#FUSES NOLVP //No low voltage prgming,
#FUSES NOMCLR
#FUSES INTRC_IO
#FUSES PUT
Don't use two oscillator fuses. LP is for a watch crystal (32.768 KHz).
INTRC_IO is the internal oscillator. Delete the LP fuse. Also, don't
enable the WDT in a test program. Delete the WDT fuse.

I have tried to disable LP fuse and WDT fuse. It's still the same. Has it anything to do with the LCD setup instead?

Quote:

What board are you using ? Post the manufacturer and part number.

It's our own board. It consists of a PIC16F1946-TQFP64 connected to a custom made LCD display, some switches and LED lights. I can send you the schematic if you give me your email address.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 21, 2011 5:55 pm     Reply with quote

OK, it's really very simple. The number shown in bold is the segment
enable bitmask:
Quote:

setup_lcd( LCD_TYPE_B | LCD_MUX13 | LCD_BIAS13 | LCD_REF_ENABLED | LCD_B_HIGH_POWER | LCD_TIMER1, 0, 0x131437);

First, convert it to binary represenation:
Code:

Register:          SE2          SE1          SE0
Value in hex:     0x13         0x14         0x37
Binary value:  0001 0011    0001 0100    0011 0111
Bit number    23.......16  15.......8    7.......0
                                  | 
                                  |
                               Note bit 10
                               above = 1.  This is the Seg10 pin.

This means you have Seg10 enabled as an LCD segment driver pin.

The 16F1947 data sheet says that when you do this, you can't use it
as an ordinary i/o pin:
Quote:
27.6 Segment Enables

The LCDSEn registers are used to select the pin
function for each segment pin. The selection allows
each pin to operate as either an LCD segment driver or
as one of the pin’s alternate functions. To configure the
pin as a segment pin, the corresponding bits in the
LCDSEn registers must be set to ‘1’.

If the pin is a digital I/O, the corresponding TRIS bit
controls the data direction. Any bit set in the LCDSEn
registers overrides any bit settings in the corresponding
TRIS register
.


So if you're not using Seg10 for your LCD, then don't set the bit for it
in the Segment Enables bitmask parameter. Change it to a zero bit.
juinhooley



Joined: 02 Aug 2011
Posts: 10

View user's profile Send private message

PostPosted: Sun Aug 21, 2011 5:59 pm     Reply with quote

Good point! I copied that line from my old code and didn't think of checking that.

It works now, with the LCD segments configured correctly.

Many thanks.
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