View previous topic :: View next topic |
Author |
Message |
Futé Guest
|
INT_EXT |
Posted: Tue Nov 12, 2002 10:27 am |
|
|
Well, It's pretty simple!
I don't know how to use Int_ext2
The following code doesn't work:
#int_ext2
__INT()
{
if (TrameEnCours==0) TrameEnCours=1;
// printf("c");
}
void main()
{
enable_interrupts(global);
enable_interrupts(INT_EXT); // ?
enable_interrupts(INT_EXT2);
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 8801 |
|
|
johnpcunningham Guest
|
Re: INT_EXT |
Posted: Tue Nov 12, 2002 10:54 am |
|
|
Try it like this:
////////////////////
#int_ext
void isr_ext()
{
if (TrameEnCours==0) TrameEnCours=1;
printf("c");
}
//////////////////
//////////////////
#int_ext2
void isr_ext2()
{
//your code here
}
//////////////
////////////////////////
void main()
{
enable_interrupts(global);
enable_interrupts(INT_EXT);
enable_interrupts(INT_EXT2);
}
///////////////////////
___________________________
This message was ported from CCS's old forum
Original Post ID: 8805 |
|
|
Futé Guest
|
Re: INT_EXT |
Posted: Wed Nov 13, 2002 1:56 am |
|
|
It still doesn't work. I don't think that I've done some silly things but we never know.
Here is my complete source code. The aim is to read RC5 code.
Even if RC5 decoding doesn't work, it should at least send a printf.
#include <18f452.h>
#fuses HS,NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
#include <string.h>
#define DATA_RC5 PIN_B2
////////////////////////////////////////////////////////////////// Variables principales
////////////////////////////////////////////////////////////////
typedef struct {
char Toggle; // 1 bit
char Adresse; // 5 bits
char Data; // 6 bits
} tCodeRC5;
tCodeRC5 CodeRC5;
char TrameEnCours;
char ErreurRC5;
void InitTelecommande();
char LireBitRC5();
void ReceptionCodeRC5();
////////////////////////////////////////////////////////////////
// Programme principal
////////////////////////////////////////////////////////////////
void main()
{
printf("Lancement en cours...\n\r");
InitTelecommande();
while (1)
{
ReceptionCodeRC5();
}
}
#int_ext
isr_ext()
{
if (TrameEnCours==0) TrameEnCours=1;
printf("c");
}
#int_ext2
isr_ext2()
{
printf("c");
}
void InitTelecommande()
{
TrameEnCours=0;
ErreurRC5=0;
enable_interrupts(global);
enable_interrupts(INT_EXT);
enable_interrupts(INT_EXT2);
}
char LireBitRC5()
{
char i;
delay_us(868);
i=DATA_RC5;
delay_us(868);
if ((i==0)&&(DATA_RC5==1))
return (1);
if ((i==1)&&(DATA_RC5==0))
return (0);
ErreurRC5++;
return (0);
}
void ReceptionCodeRC5()
{
char i,j;
if (TrameEnCours)
{
ErreurRC5=0;
delay_us(1302);
j=DATA_RC5;
delay_us(868);
if ((DATA_RC5==1)&&(j==0))
{
j=1;
} else
j=0;
// Lire Bit Ctrl
CodeRC5.Toggle=LireBitRC5();
// Lire l'adresse
CodeRC5.Adresse=0;
for (i=0;i<5;i++)
CodeRC5.Adresse |=LireBitRC5()<
// Lire les datas
CodeRC5.Data=0;
for (i=0;i<6;i++)
CodeRC5.Data|=LireBitRC5()<
TrameEnCours=0;
// Récapitulation des informations
if (j==1) printf("START\n\r");
if (ErreurRC5==0)
printf("Toggle=\%u;Adresse=\%u;Data=\%u \n\r",CodeRC5.Toggle,CodeRC5.Adresse,CodeRC5.Data);
else
printf("\%u erreur(s)",ErreurRC5);
printf("Fin de lecture.\n\r");
}
}
Another question is: How do you configure a rising or falling edge in "C" like you do ASM ? (in this case I would prefer a falling edge)
And what does INT_EXT interrupt means ? Does this correspond to INT0 ? and INT_EXT1 to INT1 ... ?
Thanks
:=Try it like this:
:=
:=////////////////////
:=#int_ext
:=void isr_ext()
:={
:=if (TrameEnCours==0) TrameEnCours=1;
:=printf("c");
:=}
:=//////////////////
:=
:=//////////////////
:=#int_ext2
:=void isr_ext2()
:={
:=//your code here
:=}
:=//////////////
:=
:=
:=////////////////////////
:=void main()
:={
:=enable_interrupts(global);
:=enable_interrupts(INT_EXT);
:=enable_interrupts(INT_EXT2);
:=}
:=///////////////////////
___________________________
This message was ported from CCS's old forum
Original Post ID: 8833 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: INT_EXT |
Posted: Wed Nov 13, 2002 12:53 pm |
|
|
:=I don't know how to use Int_ext2
:=
----------------------------------------------------
I don't work with the 18F series of PICs. But I wrote
a demo program for INT_EXT for the 16F877. It shows
a lot of the important details. It may help with your
18F project. See the following article. It has a link
to the sample code.
<a href="http://www.pic-c.com/forum/general/posts/5016.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/5016.html</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 8853 |
|
|
|