|
|
View previous topic :: View next topic |
Author |
Message |
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
ext_int |
Posted: Sun Mar 25, 2007 3:03 pm |
|
|
hi
this code dont sense external intterput..but whats wrong with it??
Code: |
#include <16f877a.h>
#include "lcd_kbd1.c"
#include <string.h>
#fuses xt,NOWDT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#byte tris_d =0x00
//#priority rda,ext //serial is higher proirety
#define address 10 // Location in EEPROM
float value = 0;
int1 flag;
#INT_EXT
void external_isr() {
// value = read_eeprom (address);
value= value+0.1003;
// write_eeprom (address, value);
//flag=1;
}
void main() {
// write_eeprom (address, value);
flag=0;
output_low(PIN_D0);
// enable_interrupts(INT_RDA);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
ext_int_edge(H_TO_L);
LCD_Init ( );
LCD_PutCmd ( CLEAR_DISP );
while(TRUE)
{
//main:
// value = read_eeprom (address);
LCD_SetPosition (LINE_16_1);//80-8f
printf(LCD_PutChar,"value:");
LCD_SetPosition (LINE_16_2);//80-8f
printf(LCD_PutChar,"\f%6.3f",value);
delay_ms(200);
// value= value+0.0003;
// if (flag==1) {
// value= value+0.1003;
// output_high(PIN_D7);
// delay_ms(500);
// flag=0;
// }
}//while
}//MAIN
|
thank you |
|
|
Ttelmah Guest
|
|
Posted: Mon Mar 26, 2007 4:33 am |
|
|
You can't read/write a floating point number to/from the EEPROM like this. You need to perform four transfers to move the individual bytes, seperating them, and then putting them together again, using 'make8/make32', or a union. Do a search on here for dozens of examples of how to do this.
Almost certainly, the interrupt is occurring, and just not giving the data change you expect.
Seperately, _do not_ change the active interrupt edge, after enabling the interrupt. This can give a spurious interrupt. Change the edge, clear the interrupt, then enable it.
Consider _not_ using floating point arithmetic inside the interrupt hadler, and also, not writing to the eeprom in here. Both are _slow_, and having the routines both inside and outside the interrupt, means that the interrupt will be disabled for long periods in the main.
Best Wishes |
|
|
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
|
Posted: Mon Mar 26, 2007 6:03 am |
|
|
yes you are right,,,i change it onto read and write flaot value like in the faq
its ok!!
but still lcd proplem |
|
|
hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
|
Posted: Tue Mar 27, 2007 6:06 am |
|
|
i think lcd driver use port b..so it cause problem
thank you |
|
|
|
|
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
|