|
|
View previous topic :: View next topic |
Author |
Message |
TaeHwan Sung Guest
|
How to use #INT_AD with PIC16F676? |
Posted: Fri Jul 25, 2003 1:31 am |
|
|
hi!
How to use #INT_AD with PIC16F676?
#int_ad
adc_handler()
{
BYTe tmp;
tmp=read_adc();
}
compiler message : ERROR invalid pre-processor directive
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516340 |
|
|
R.J.Hamlett Guest
|
Re: How to use #INT_AD with PIC16F676? |
Posted: Fri Jul 25, 2003 2:12 am |
|
|
:=hi!
:=How to use #INT_AD with PIC16F676?
:=
:=#int_ad
:=adc_handler()
:={
:= BYTe tmp;
:=
:= tmp=read_adc();
:=}
:=compiler message : ERROR invalid pre-processor directive
Unfortunately, the standard setup, leaves the AD interrupt turned off in the device editor for this chip (I think they copied the file for the 630, which doesn't have the AD). If you have the windows based development enviroment, select the device editor, find the chip, and in the 'interrupts' window, turn on ADIF, at address 0C.6. Save this, and the interrupt will then be available!.
If you don't have the device editor, contact CCS, and they should be able to send you a file with this turned on, allmost immediately.
One 'fault', in the code as written, is the syntax of the 'read_adc' call. You need to use the form:
tmp=read_adc(ADC_READ_ONLY);
otherwise this call, will trigger the ADC again.
Also in the main code somewhere, you will need a similar call, with 'ADC_START_ONLY', which will start the conversion, and the interrupt will then occur when the conversion is finished.
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516342 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: How to use #INT_AD with PIC16F676? |
Posted: Fri Jul 25, 2003 12:08 pm |
|
|
:=hi!
:=How to use #INT_AD with PIC16F676?
:=
:=#int_ad
:=adc_handler()
:={
:= BYTe tmp;
:=
:= tmp=read_adc();
:=}
:=compiler message : ERROR invalid pre-processor directive
------------------------------------------------------------
If your version of the compiler does not support a certain
interrupt, and if you can't get CCS to help you quickly,
then you can use the #int_default directive to fix the problem.
Example:
Code: | int16 adc_result;
#bit ADIF_BIT = 0x0C.6
#bit ADIE_BIT = 0x8C.6
#int_default
void default_isr(void)
{
if(ADIE_BIT) // Is the interrupt enabled ?
if(ADIF_BIT) // If so, is the interrupt flag set ?
{
adc_result = read_adc(ADC_READ_ONLY);
ADIF_BIT = 0; // Clear the interrupt flag
}
} |
Edited on Feb. 7, 2005 to remove the double-spacing in the code above
that happened when this post was moved to the new board.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516363 |
|
|
|
|
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
|