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

Problem with 16F917 and External clock source

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



Joined: 08 Mar 2008
Posts: 12

View user's profile Send private message

Problem with 16F917 and External clock source
PostPosted: Sat Mar 08, 2008 5:40 pm     Reply with quote

I'm using the Microchip Picdem Mechatronics board and CCS V4.068. I'm trying to use the lcd display along with Timer1 and an external source on T1CKI. I'm trying to measure the time between pulses from the optical interrupter circuit. I'm using the lcd display driver that 'pcm programmer' wrote.
http://www.ccsinfo.com/forum/viewtopic.php?t=32774&highlight=16f917+lcd

Timer1 works great until I call setup_lcd(LCD_MUX14 | LCD_BIAS_PINS, 0); and then the timer quits counting.

The program I wrote is just a ccs c program to do the same thing as project 5 written in assy. The assy program from Microchip works fine using timer1 and the lcd.

I can post the code if requested. Could this be a CCS problem or maybe my programming? Any ideas?

Thanks,

JC
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 09, 2008 3:05 pm     Reply with quote

There's an incorrect entry in the digit tables. The last entry for DIGIT1
should be COM3+21 (and not COM3+10). In other words, it was
enabling the output driver for segment 10, and that pin is also used for
the Timer1 external clock input. Once you change it to segment 21,
it will fix the problem. I have edited the code in the post that has
driver source code to use the correct value. Thanks for finding that.
raptorman



Joined: 08 Mar 2008
Posts: 12

View user's profile Send private message

It related to the LCD segments
PostPosted: Sun Mar 09, 2008 4:19 pm     Reply with quote

This is the setup for the lcd:
setup_lcd( LCD_INTRC | LCD_MUX14 | LCD_BIAS_PINS, 0);

Well I can make the counter and the LCD work by doing the following:
#BIT LCDSE1 = 0x11D.2
LCDSE1 = 0;
The above code disables segment 10 output which isn't used for the lcd but is the same pin as the T1CKI external clk for timer1.

I would think that CCS would add SEG constants that I can add to setup_lcd to only use the needed segments. You can find where they have segs under setup_lcd in the CCS manual, but in the device 16F917.h file there are no constants listed for segs.

Shouldn't this be something that CCS fixes?
raptorman



Joined: 08 Mar 2008
Posts: 12

View user's profile Send private message

Excellent!
PostPosted: Sun Mar 09, 2008 4:21 pm     Reply with quote

Thanks for taking a look at my problem.

I didn't notice a reply until I posted the last message.

What do you think about being able to add what segments you want to use and not enabling them all?

Thanks again,

JC
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 09, 2008 4:27 pm     Reply with quote

If you use the lcd_symbol() function in your program, the compiler looks
at the 2nd parameter to see what segments are used. It then enables
those segment drivers by writing to the LCDSE0, LCDSE1, and LCDSE2
registers.
raptorman



Joined: 08 Mar 2008
Posts: 12

View user's profile Send private message

PostPosted: Sun Mar 09, 2008 4:35 pm     Reply with quote

Thanks pcm programmer. I get the big picture now. It always helps to read the manual again. I always have used 44780 style lcds until getting this board. Something new is always a challenge.

Thanks again for your code and help.

JC
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