View previous topic :: View next topic |
Author |
Message |
raptorman
Joined: 08 Mar 2008 Posts: 12
|
Problem with 16F917 and External clock source |
Posted: Sat Mar 08, 2008 5:40 pm |
|
|
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
|
|
Posted: Sun Mar 09, 2008 3:05 pm |
|
|
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
|
It related to the LCD segments |
Posted: Sun Mar 09, 2008 4:19 pm |
|
|
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
|
Excellent! |
Posted: Sun Mar 09, 2008 4:21 pm |
|
|
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
|
|
Posted: Sun Mar 09, 2008 4:27 pm |
|
|
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
|
|
Posted: Sun Mar 09, 2008 4:35 pm |
|
|
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 |
|
|
|