|
|
View previous topic :: View next topic |
Author |
Message |
Calamar
Joined: 07 Sep 2003 Posts: 60 Location: Buenos Aires (Argentina)
|
wrong characters in lcd without disbable_global |
Posted: Tue Apr 25, 2006 7:01 am |
|
|
This code works
compiler versions
3.245
3.222
Code: |
#include <18f452.h>
#fuses HS, NOWDT, PUT, NOLVP, BORV42, NOPROTECT, CCP2B3
#use delay (clock=10000000)
#include <lcd.h>
#bit TMR3_flag = 0xfa1.0 // flag bit from TMR3
int32 TMR3_pulses = 0;
int32 frecuency = 0;
int TMR3_rollOver;
char line_1[16] = "";
int contador;
#INT_TIMER3
tmr3_isr()
{
TMR3_rollOver++;
}
#INT_CCP2
void ccp2_isr()
{
static int32 rollOver_amount = 65536;
TMR3_pulses = rollOver_amount * (int32)TMR3_rollOver;
TMR3_pulses += (int32) CCP_2;
frecuency = 400000000 / TMR3_pulses;
TMR3_rollOver = 0;
TMR3_flag = false;
set_timer3(0);
}
void main(void)
{
int16 Counter;
SET_TIMER3(0);
SETUP_TIMER_3(T3_DIV_BY_1|T3_INTERNAL);
SETUP_CCP2(CCP_CAPTURE_DIV_16|CCP_USE_TIMER3);
ENABLE_INTERRUPTS(INT_CCP2);
ENABLE_INTERRUPTS(INT_TIMER3);
ENABLE_INTERRUPTS(GLOBAL);
lcd_init();
counter = 1000;
while(true)
{
lcd_gotoxy(1,1);
counter--;
if(!counter)
{
disable_interrupts(global);
printf(lcd_putc, "f = %6lu ",frecuency);
enable_interrupts(global);
}
}
}
|
Wrong charater apper when itsnt
disable de global interrupt:
Code: | // disable_interrupts(global);
printf(lcd_putc, "f = %6lu ",frecuency);
// enable_interrupts(global); |
any idea ? _________________ Best Regards
Daniel H. Sagarra
La Plata (Argentina) |
|
|
Guest
|
|
Posted: Tue Apr 25, 2006 8:50 am |
|
|
This code do the same, just
uncomment disable_interrrups(gloabal)
and work
Code: | #include <18f452.h>
#fuses HS, NOWDT, PUT, NOLVP, BORV42, NOPROTECT, CCP2B3
#use delay (clock=10000000)
#bit TMR3_flag = 0xfa1.0 // flag bit from TMR3
int32 TMR3_pulses = 0;
int32 frecuency = 0;
int TMR3_rollOver;
char line_1[32] = "";
int contador;
#INT_CCP2
void ccp2_isr()
{
int32 rollOver_amount = 65536;
TMR3_pulses = rollOver_amount * (int32)TMR3_rollOver;
TMR3_pulses += (int32) CCP_2;
frecuency = 400000000 / TMR3_pulses;
TMR3_rollOver = 0;
TMR3_flag = false;
set_timer3(0);
}
#include <lcd.h>
void main(void)
{
SET_TIMER3(0);
SETUP_TIMER_3(T3_DIV_BY_1|T3_INTERNAL);
SETUP_CCP2(CCP_CAPTURE_DIV_16|CCP_USE_TIMER3);
ENABLE_INTERRUPTS(INT_CCP2);
ENABLE_INTERRUPTS(INT_TIMER3);
ENABLE_INTERRUPTS(GLOBAL);
lcd_init();
while(true)
{
lcd_gotoxy(1,1);
// disable_interrups(gloabal);
sprintf(line_1, "f = %6lu \nHola la prerinola",frecuency);
enable_interrups(gloabal);
printf(lcd_putc,"%s", line_1);
delay_ms(1000);
}
} |
|
|
|
Guest
|
|
Posted: Tue Apr 25, 2006 9:03 am |
|
|
sorry I miss copy&paste this ISR in above message
from my code;
Code: | #INT_TIMER3
tmr3_isr()
{
TMR3_rollOver++;
} |
|
|
|
Guest
|
|
Posted: Tue Apr 25, 2006 5:54 pm |
|
|
What about that ???
Code: | Address Symbol Name Value
001D frecuency_1 0x00001AD4
0026 line_1 "f = 686f
Hello World"
0026 [0] f
0027 [1]
0028 [2] =
0029 [3]
002A [4]
002B [5]
002C [6] 6
002D [7] 8
002E [8] 6
002F [9] f
0030 [10]
0031 [11]
0032 [12]
0033 [13]
0034 [14]
0035 [15] .
0036 [16] H
0037 [17] e
0038 [18] l
0039 [19] l
003A [20] o
003B [21]
003C [22] W
003D [23] o
003E [24] r
003F [25] l
0040 [26] d
0041 [27] .
0042 [28] .
0043 [29] .
0044 [30] .
0045 [31] . |
A break was insterted in delay_ms, runing several
times.... and it fail (686f, f->? )
the code:
Code: | #include <18f452.h>
#fuses HS, NOWDT, PUT, NOLVP, BORV42, NOPROTECT, CCP2B3
#use delay (clock=10000000)
#bit TMR3_flag = 0xfa1.0 // flag bit from TMR3
int32 TMR3_pulses = 0;
int32 frecuency_1 = 0;
int32 frecuency = 0;
int TMR3_rollOver;
char line_1[32] = "";
int1 write_enable = 0;
#INT_TIMER3
tmr3_isr()
{
TMR3_rollOver++;
}
#INT_CCP2
void ccp2_isr()
{
int32 rollOver_amount = 65536;
TMR3_pulses = rollOver_amount * (int32)TMR3_rollOver;
TMR3_pulses += (int32) CCP_2;
frecuency = 400000000 / TMR3_pulses;
TMR3_rollOver = 0;
TMR3_flag = false;
set_timer3(0);
if(write_enable) frecuency_1 = frecuency;
}
#include <lcd.h>
void main(void)
{
SET_TIMER3(0);
SETUP_TIMER_3(T3_DIV_BY_1|T3_INTERNAL);
SETUP_CCP2(CCP_CAPTURE_DIV_16|CCP_USE_TIMER3);
ENABLE_INTERRUPTS(INT_CCP2);
ENABLE_INTERRUPTS(INT_TIMER3);
ENABLE_INTERRUPTS(GLOBAL);
lcd_init();
while(true)
{
lcd_gotoxy(1,1);
write_enable = false;
sprintf(line_1, "f = %6lu \nHello World",frecuency_1);
write_enable = true;
printf(lcd_putc,"%s", line_1);
delay_ms(100);
lcd_gotoxy(6,1);
}
} |
|
|
|
|
|
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
|