|
|
View previous topic :: View next topic |
Author |
Message |
Kevin Howell Guest
|
Touch devices and Ver 3.142 |
Posted: Wed Feb 19, 2003 8:41 am |
|
|
HELP!!!!!!!!!!!!!
I have tested touch devices (DS1990) with no problem on Pin A0 using Ver2 compiler...(using a 16F84) I moved to the Ver 3 compiler (and to the 16F628) and my touch program only works on the default pin in the touch.c file which is PIN_B0. When testing on a 16F877 and Ver2 compiler PINA0 works fine, but again when using the Ver3 compiler and the 18F452 it doesn't work on PINA0 (Only on PINB0).
Does anyone know why this could happen. The touch_present function does not read the input correctly . I have viewed the output from PIN_A0 with a scope and all seems fine. Has it got anything to do with the output_float function?
here is the function:
byte touch_present() {
boolean present;
output_low(TOUCH_PIN);
delay_us(500);
output_float(TOUCH_PIN);
if(!input(TOUCH_PIN))
return(FALSE);
delay_us(65);
present=!input(TOUCH_PIN);
delay_us(240);
if(present)
return(TRUE);
else
return(FALSE);
}
Any help would be appreciated...
___________________________
This message was ported from CCS's old forum
Original Post ID: 11875 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Touch devices and Ver 3.142 |
Posted: Wed Feb 19, 2003 12:15 pm |
|
|
:=HELP!!!!!!!!!!!!!
:=
:=
:=I have tested touch devices (DS1990) with no problem on Pin A0 using Ver2 compiler...(using a 16F84) I moved to the Ver 3 compiler (and to the 16F628) and my touch program only works on the default pin in the touch.c file which is PIN_B0. When testing on a 16F877 and Ver2 compiler PINA0 works fine, but again when using the Ver3 compiler and the 18F452 it doesn't work on PINA0 (Only on PINB0).
:=
:=Does anyone know why this could happen. The touch_present function does not read the input correctly . I have viewed the output from PIN_A0 with a scope and all seems fine. Has it got anything to do with the output_float function?
:=
------------------------------------------------------
You didn't post the statements that define TOUCH_PIN
and TOUCH_PIN_BIT. The 18F452 has a very different
address for Port A, compared to the 16F series PICs.
Make sure you put in the correct value: 0xF80
For the 16F628, it has comparators on port A.
Did you turn them off ? ie:
setup_comparator(NC_NC_NC_NC);
___________________________
This message was ported from CCS's old forum
Original Post ID: 11892 |
|
|
Kevin Howell Guest
|
Re: Touch devices and Ver 3.142 |
Posted: Thu Feb 20, 2003 2:13 am |
|
|
#ifndef TOUCH_PIN
#define TOUCH_PIN PIN_A0
#bit TOUCH_PIN_BIT = 6.0
#endif
This code in the touch.c file. I have't changed anything and A0's address is taken from the 18f452 header file!
:=:=HELP!!!!!!!!!!!!!
:=:=
:=:=
:=:=I have tested touch devices (DS1990) with no problem on Pin A0 using Ver2 compiler...(using a 16F84) I moved to the Ver 3 compiler (and to the 16F628) and my touch program only works on the default pin in the touch.c file which is PIN_B0. When testing on a 16F877 and Ver2 compiler PINA0 works fine, but again when using the Ver3 compiler and the 18F452 it doesn't work on PINA0 (Only on PINB0).
:=:=
:=:=Does anyone know why this could happen. The touch_present function does not read the input correctly . I have viewed the output from PIN_A0 with a scope and all seems fine. Has it got anything to do with the output_float function?
:=:=
:=------------------------------------------------------
:=
:=You didn't post the statements that define TOUCH_PIN
:=and TOUCH_PIN_BIT. The 18F452 has a very different
:=address for Port A, compared to the 16F series PICs.
:=Make sure you put in the correct value: 0xF80
:=
:=For the 16F628, it has comparators on port A.
:=Did you turn them off ? ie:
:=
:=setup_comparator(NC_NC_NC_NC);
___________________________
This message was ported from CCS's old forum
Original Post ID: 11907 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Touch devices and Ver 3.142 |
Posted: Thu Feb 20, 2003 12:23 pm |
|
|
:=#ifndef TOUCH_PIN
:=
:=#define TOUCH_PIN PIN_A0
:=#bit TOUCH_PIN_BIT = 6.0
:=
:=#endif
:=
:=This code in the touch.c file. I have't changed anything and A0's address is taken from the 18f452 header file!
:=
--------------------------------------------
This next line defines a bit, within an i/o port on a PIC.
TOUCH_PIN_BIT = 6.0
The "6" is the address of Port B in a 16-series PIC.
If you want to change it to use Port A, then you have to
read the data sheet, and then you'll see that Port A has
an address of 5 for a 16-series PIC.
If you're using an 18F series PIC, it has an entirely different
memory map. Get the data sheet for a 18F452, and look at
table 4-1. In the lower right corner of the page, it gives
the addresses for each port. Just substitute that number
instead of the "6".
___________________________
This message was ported from CCS's old forum
Original Post ID: 11924 |
|
|
Kevin Howell Guest
|
Re: Touch devices and Ver 3.142 |
Posted: Sat Feb 22, 2003 1:51 pm |
|
|
:=:=#ifndef TOUCH_PIN
:=:=
:=:=#define TOUCH_PIN PIN_A0
:=:=#bit TOUCH_PIN_BIT = 6.0
:=:=
:=:=#endif
:=:=
:=:=This code in the touch.c file. I have't changed anything and A0's address is taken from the 18f452 header file!
:=:=
:=--------------------------------------------
:=
:=This next line defines a bit, within an i/o port on a PIC.
:=TOUCH_PIN_BIT = 6.0
:=The "6" is the address of Port B in a 16-series PIC.
:=
:=If you want to change it to use Port A, then you have to
:=read the data sheet, and then you'll see that Port A has
:=an address of 5 for a 16-series PIC.
:=
:=If you're using an 18F series PIC, it has an entirely different
:=memory map. Get the data sheet for a 18F452, and look at
:=table 4-1. In the lower right corner of the page, it gives
:=the addresses for each port. Just substitute that number
:=instead of the "6".
:=
I don't think you are correct, the "6" refers to bit 6 in the pointer 'data' in the write function. Touch_pin_bit is not used in the read function and what I am trying to do is read from the device not write...
___________________________
This message was ported from CCS's old forum
Original Post ID: 12016 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Touch devices and Ver 3.142 |
Posted: Sun Feb 23, 2003 12:10 am |
|
|
:=I don't think you are correct, the "6" refers to bit 6 in the pointer 'data' in the write function. Touch_pin_bit is not used in the read function and what I am trying to do is read from the device not write...
-----------------------------------------------------------
That's not true. The "6" refers to a memory address.
Since the registers in a PIC are memory mapped, you can
use the #bit directive to allow access to individual
bits of a PIC register.
The "6" refers to Port B.
The "0" refers to bit 0, within memory address 6.
ie., bit 0 of Port B.
#bit TOUCH_PIN_BIT = 6.0
Look at another example in the CCS driver file, EX_GLINT.C.
This file is in c:\Program Files\Picc\Examples
Here are some definitions that CCS has in that file:
#byte status = 3
#bit zero_flag = status.2
#bit t0if = 0xb.2
The 1st line defines the address of the PIC's status register.
It's at address 3. That's in the data sheet.
The 2nd line defines a bit called "zero_flag". It's defined
as bit 2 of the status register. Look in the data sheet for
a 16F877. Bit 2 of the Status register is the zero flag.
Look at Table 2-1 in the 16F877 data sheet.
The 3rd line defines a bit called "t0if" as being bit 2
of the register at address 0x0b. If you look at Table 2-1,
0x0b is the INTCON register and bit 2 is the T0IF flag.
---
Change your code to fit the data sheet for the device that
you're using (16F or 18F), and you will be one step closer
to making it work.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12029 |
|
|
Kevin Howell Guest
|
Re: Touch devices and Ver 3.142 |
Posted: Mon Feb 24, 2003 8:14 am |
|
|
:=:=I don't think you are correct, the "6" refers to bit 6 in the pointer 'data' in the write function. Touch_pin_bit is not used in the read function and what I am trying to do is read from the device not write...
:=-----------------------------------------------------------
:=
:=That's not true. The "6" refers to a memory address.
:=Since the registers in a PIC are memory mapped, you can
:=use the #bit directive to allow access to individual
:=bits of a PIC register.
:=
:=The "6" refers to Port B.
:=The "0" refers to bit 0, within memory address 6.
:=ie., bit 0 of Port B.
:=
:=#bit TOUCH_PIN_BIT = 6.0
:=
:=Look at another example in the CCS driver file, EX_GLINT.C.
:=This file is in c:\Program Files\Picc\Examples
:=
:=Here are some definitions that CCS has in that file:
:=
:=#byte status = 3
:=#bit zero_flag = status.2
:=#bit t0if = 0xb.2
:=
:=The 1st line defines the address of the PIC's status register.
:=It's at address 3. That's in the data sheet.
:=
:=The 2nd line defines a bit called "zero_flag". It's defined
:=as bit 2 of the status register. Look in the data sheet for
:=a 16F877. Bit 2 of the Status register is the zero flag.
:=Look at Table 2-1 in the 16F877 data sheet.
:=
:=The 3rd line defines a bit called "t0if" as being bit 2
:=of the register at address 0x0b. If you look at Table 2-1,
:=0x0b is the INTCON register and bit 2 is the T0IF flag.
:=
:=---
:=Change your code to fit the data sheet for the device that
:=you're using (16F or 18F), and you will be one step closer
:=to making it work.
You are so right!!!!!!!!!!!!! I changed it to the correct address and everything works!!!! Please just explain to me why it affects the software if I dont make use of the defined bit. I never call the write function so why would it influence the other functions?
Thanks a lot for you help!!!!
Kevin
___________________________
This message was ported from CCS's old forum
Original Post ID: 12053 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Touch devices and Ver 3.142 |
Posted: Mon Feb 24, 2003 2:07 pm |
|
|
:=:=Change your code to fit the data sheet for the device that
:=:=you're using (16F or 18F), and you will be one step closer
:=:=to making it work.
:=
:=You are so right!!!!!!!!!!!!! I changed it to the correct address and everything works!!!! Please just explain to me why it affects the software if I dont make use of the defined bit. I never call the write function so why would it influence the other functions?
-------------------------------------------------------
If changing the address causes the program to work,
I would think that TOUCH_PIN_BIT must be used somewhere.
As far as I can tell, it's only used in the touch_write_byte()
function.
The CCS example file, EX_TOUCH.C, does call the
touch_write_byte() function in line 59.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12070 |
|
|
|
|
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
|