Professional Documents
Culture Documents
Author Message
/* Pin assignation */
#bit LED = 0xF81.7
/* function header */
#INT_EXT
void test();
void main()
{
SET_TRIS_B(0x00);
ext_int_edge(H_TO_L);
disable_interrupts(GLOBAL);
enable_interrupts(INT_EXT);
LED = 0;
while(1){}
}
#INT_EXT
void test()
{
1 от 8 27.2.2007 г. 16:36
CCS :: View topic - interrupt problem after migration 16f877 to ... http://ccsinfo.com/forum/viewtopic.php?t=19397&highlight=int0...
LED = 1;
delay_ms(1000);
LED = 0;
}
It's working well with the 16f877 and not on the 18f452.... why
Thanx a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!
David
change:
Joined: 14 May 2004
Posts: 270
disable_interrupts(GLOBAL);
enable_interrupts(INT_EXT);
to:
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
2 от 8 27.2.2007 г. 16:36
CCS :: View topic - interrupt problem after migration 16f877 to ... http://ccsinfo.com/forum/viewtopic.php?t=19397&highlight=int0...
It's not working on my real code... (it was only a test the old one) (I cut some innutil parts )
Code :
#include <18F452.h>
#DEVICE ADC=10 *=16
#include <stdlib.h>
/* Functions header */
#INT_RDA
void port(); //RS232
#INT_EXT
void ch_scr(); // Refresh LCD
#INT_TIMER1
void acq(); //acquisition timer
void main()
{
//Initialisation du LCD
init_lcd();
//Initialisation du timer
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
3 от 8 27.2.2007 г. 16:36
CCS :: View topic - interrupt problem after migration 16f877 to ... http://ccsinfo.com/forum/viewtopic.php?t=19397&highlight=int0...
enable_interrupts(GLOBAL);
enable_interrupts(INT_EXT);
enable_interrupts(INT_RDA);
enable_interrupts(INT_TIMER1);
while(1)
{
delay_ms(100);
if(flag_acq) //Si le flag est à ON, on fait une acquisition
acquisition();
/* Other Functions */
void communication()
{
if(!strcmp(string, id)) //est-ce que le data recu est km13?
{
creer_trame(); //on monte une trame pour envoyer les donnees
printf("%s", trame); //on envoie les donnees
}
4 от 8 27.2.2007 г. 16:36
CCS :: View topic - interrupt problem after migration 16f877 to ... http://ccsinfo.com/forum/viewtopic.php?t=19397&highlight=int0...
printl(lcd, 1,1);
sprintf(lcd, "Courant du 48V:%2.1f", ht_courant);
printl(lcd, 2,1);
}
//Affichage de la température et du fonctionnement de la génératrice
else if(scr == 3)
{
if(gen)
strcpy(string, "en marche");
else
strcpy(string, "hors fonction");
5 от 8 27.2.2007 г. 16:36
CCS :: View topic - interrupt problem after migration 16f877 to ... http://ccsinfo.com/forum/viewtopic.php?t=19397&highlight=int0...
#INT_RDA
void port()
{
gets(string);
flag_com = 1;
}
//btn
#INT_EXT
void ch_scr()
{
flag_btn = 1;
}
Thanx!!!
DAvid
SET_TRIS_B(0x00);
How many times per second is your Timer1 generating an interrupt? If this is more then 10
Joined: 18 Mar 2004
Posts: 1333 times per second, than flag_acq will always be true and your communication or lcd-routines are
Location: The Netherlands never called....
Hello !!!
Joined: 23 May 2004
Posts: 11 My button is on pin B0 (int0). So I can not put the TrisB at 00, at lease 01.
Location: Montreal For the Timer1, I put // (comment) it and it's not working to...
I'm so disappointed :(
Tanks
David
6 от 8 27.2.2007 г. 16:36
CCS :: View topic - interrupt problem after migration 16f877 to ... http://ccsinfo.com/forum/viewtopic.php?t=19397&highlight=int0...
I very doubt the statement that this works on the 16f877 with
Code:
Disable_interrupts(GLOBAL);
Quote:
Quote:
Joined: 18 Mar 2004
Posts: 1333 I very doubt the statement that this works on the 16f877 with
Location: The Netherlands Code:
Disable_interrupts(GLOBAL);
Sorry Guest, this has already been solved in his later postings.
I still think his problem is with the Timer1, it looks too fast to me:
Code:
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
In the Timer1 handler the flag_acq will be set. This combined with the delay_ms and the
repeated if..else if...else construction will make sure he will only have time to execute the
acquisition() function and nothing else.
Code:
while(1)
{
delay_ms(100);
if(flag_acq) //Si le flag est à ON, on fait une acquisition
acquisition();
7 от 8 27.2.2007 г. 16:36
CCS :: View topic - interrupt problem after migration 16f877 to ... http://ccsinfo.com/forum/viewtopic.php?t=19397&highlight=int0...
8 от 8 27.2.2007 г. 16:36