View previous topic :: View next topic |
Author |
Message |
JerryR
Joined: 07 Feb 2008 Posts: 167
|
Touchpad issues PIC16F1829 |
Posted: Mon Feb 29, 2016 12:43 pm |
|
|
Hello Group:
I am having issues compiling simple touchpad code for a 16F1829 target.
I am using CCS PCWH 5.021 with MPLAB 8.90 IDE.
Compile fails with "Error 99 "Touch_Test.c" Line 9(5,74): Option invalid Bad Pin: 119"
Here's the simple code:
Code: |
#include <16f1829.h>
#fuses HS,NOWDT,NOPUT
#use delay(INTERNAL= 8mhz)
#define GREEN_LED pin_b7
#define GREEN_LED pin_c4
#use touchpad(scantime=32ms,threshold=7,pin_C3='7',pin_C7='9',pin_b5='1')
void main()
{
INT i;
TOUCHPAD_STATE(1);
enable_interrupts(GLOBAL);
while (TRUE)
{
i=touchpad_getc();
}
}
|
Any suggestions? THANKS! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Mon Feb 29, 2016 2:17 pm |
|
|
though I've never used the touchpad peripheral...
this...
enable_interrupts(GLOBAL);
is NEVER a good thing to do unless you have ISRs coded !!
also having 2 define green_led isn't a good thing either....
EDIT: OK the enable _global is OK...looked it up...
2 defines does error..
for some reason pin C7 and B5 are not valid...delete them and it will compile after define a RED led not 2 green ones.
EDIT: OK B4,B5,C6 and C7 are the 4 'extended' inputs for the 1829 and NONE are liked by the compilers. I'm assuming it might have to do with how the 'touchpad' code was created as the original 8 pins are OK.
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 29, 2016 2:56 pm |
|
|
I did a quick test, and it doesn't like pins B5 or C7. It accepts pins A0-A2,
A4, and C0-C3. These are the same pins that work on the 16F1828.
This looks like the usual CCS deal where they quickly add a new chip to
their database by copying the data from a similar chip. But then it turns
out the new chip has more features, which don't get implemented on the
initial release.
If you have the full IDE of the compiler, it may be possible to edit the
data with the Device Editor. I don't have the full IDE.
In any event, you should contact CCS support and ask them to add the
missing touch pins for the 16F1829. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Mon Feb 29, 2016 3:18 pm |
|
|
Yes, it is adjustable in the IDE.
Middle window. Bottom line 'Other features'. Then look down the list for 'Cap Sense Mod'. This then has five selectable lines for the CSM. It's on the penultimate one. Problem though is you cannot tell what the lines actually say - they are too wide for the window, so you can only see the first four pins actually selected. Duh....
The next line starts the same, but what it goes on to say would only be found by trying it. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Mon Feb 29, 2016 4:19 pm |
|
|
It looks like CCS only tests or uses 3 bits for the 'pin selection' even though uC says up to 16 pins 'could' be used.
It's a tad more confusing as a 'USE xxxxxx' feature isn't really a 'nice' driver making it harder to decipher and alter.
I suppose one could cut code with and then without the use touchpad(), dump the listings, compare, disassemble the code..........but..
easier to contact CCS have them do it ! besides it's snowing here and I have to do real work...
been a nice mental challenge though !
Jay |
|
|
JerryR
Joined: 07 Feb 2008 Posts: 167
|
|
Posted: Tue Mar 01, 2016 6:53 am |
|
|
Hello group and thanks!
Yes, I was in the middle of cutting and pasting lines when I foud that the code would compile, Sorry for sloppy code. I'm just using it to get my point across about the TouchCap channels.
Yes, I'll contact CCS today and ask them to edit the touch pins. Kinda thought that was the issue.
Thanks again for the sanity-check group! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Tue Mar 01, 2016 7:33 am |
|
|
Had another look at the listing....
The 'touchpad' code is at the top and there's a 'table' of 16 entries which magically have the 'names' of the pins you want to access. It's interesting the table does hold all 16 BUT 0x07 is put into the last 8 ! I presume it's used as a test for 'valid pin'. There's also a lot of lines that clear bit 3, which would limit the range of pins to just the lower 8.
It 'should' be an easy fix for CCS to patch the code.
Jay |
|
|
JerryR
Joined: 07 Feb 2008 Posts: 167
|
|
Posted: Tue Mar 01, 2016 7:35 am |
|
|
Thanks temtronic!
Yes, I have already alerted CCS to this issue. Let's see what they come back with. All the best! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Tue Mar 01, 2016 7:54 am |
|
|
Changing it in the IDE, does let it accept the extra pins.
If you have the IDE, try it and see if it works. |
|
|
JerryR
Joined: 07 Feb 2008 Posts: 167
|
|
Posted: Tue Mar 01, 2016 7:59 am |
|
|
Ttelmah:
I'll give it a try if CCS doesn't respond today. I have schedules to keep.
Thanks! |
|
|
JerryR
Joined: 07 Feb 2008 Posts: 167
|
|
Posted: Tue Mar 01, 2016 11:07 am |
|
|
CCS came through and updated the devices file. I can't see a way to attach it here for the group, however.
Working now. Thanks to all. |
|
|
|