|
|
View previous topic :: View next topic |
Author |
Message |
agrj
Joined: 26 Sep 2003 Posts: 48
|
BIT_SET and V 3.249 problems |
Posted: Thu Mar 30, 2006 9:09 am |
|
|
Hi,
the BIT_SET function is not working in the compiler version 3.249. it was working fine
with the 3.236 version and when I update it, it stop to work.
do you have any solutions for it?
thanks |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Mar 30, 2006 9:25 am |
|
|
Works for me with int8. Can you be more specific?
Code: | #include <18F4525.h>
#use delay(clock=12000000)
#fuses HS,NOWDT,NOLVP,PROTECT,PUT,BROWNOUT
#use rs232(baud=19200,xmit=PIN_E0,INVERT,stream=DEBUG,DISABLE_INTS) // STDERR(same as DEBUG)
#case
#zero_ram
//======== MAIN =======//
void main(void)
{
int8 x;
setup_adc_ports(NO_ANALOGS);
set_tris_a(0);set_tris_b(0);set_tris_c(0);set_tris_d(0);set_tris_e(0);
fprintf(DEBUG,"\n\r");
fprintf(DEBUG,"STARTING \n\r");
x=0;
fprintf(DEBUG,"%u\n\r",x);
bit_set(x,0);
fprintf(DEBUG,"%u\n\r",x);
while (TRUE){
}
}
|
|
|
|
agrj
Joined: 26 Sep 2003 Posts: 48
|
|
Posted: Thu Mar 30, 2006 9:49 am |
|
|
this is the routine.
Code: |
if (P_PB[c].total_cont >= CNT_db) /* se o contador for maior que a defini��o de filtro, fa�a: */
{
P_PB[c].total_cont = CNT_db; /* mant�m o valor */
if (P_PB[c].bit_a == FALSE) /* se "P_PB[c].bit_a" for zero, fa�a: */
BIT_CLEAR(Byte_validoB,c); /* seta bit "c" de "Byte_validoB" */
else /* se n�o, fa�a: */
BIT_SET(Byte_validoB,c); /* zera bit "c" de "Byte_validoB" */
}
|
The variable Byte_ValidoB is int.
thanks |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Mar 30, 2006 11:03 am |
|
|
It is still working. Post a complete program. With only a few lines. Like I did.
One of the line should be a bit_set that shows it Not working. |
|
|
agrj
Joined: 26 Sep 2003 Posts: 48
|
|
Posted: Thu Mar 30, 2006 12:22 pm |
|
|
It�s a part of a huge program (more than 20000 lines)!!
when the condition is TRUE, the correspondent BIT is never set. if I use the 3.236 version everything works fine.
I will try to create a little program with the same routine and see what happens.
thanks |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Mar 30, 2006 2:51 pm |
|
|
Quote: |
BIT_SET(Byte_validoB,c); /* zera bit "c" de "Byte_validoB" */
|
At least tell us how did you define the bit 'c'
Humberto |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Mar 30, 2006 4:11 pm |
|
|
20000 lines. I'm glad I'm not you ; )
This program shows your code chunk. It works as I expect.
Byte_validoB is 1 then 3 then 7, that is bit0 is set then bit 1 then bit2.
I forced your code chunk into the else(bit_set) part.
Code: | #include <18F4525.h>
#use delay(clock=12000000)
#fuses HS,NOWDT,NOLVP,PROTECT,PUT,BROWNOUT
#use rs232(baud=19200,xmit=PIN_E0,INVERT,stream=DEBUG,DISABLE_INTS) // STDERR(same as DEBUG)
#case
#zero_ram
//======================= MAIN ============================//
void main(void){
struct jnk_def{
int8 total_cont;
int8 bit_a:1; //one bit TRUE or FALSE
int8 bit_b:7; //the rest of the byte waisted
}P_PB[3];
int8 Byte_validoB,c,CNT_db;
setup_adc_ports(NO_ANALOGS);
set_tris_a(0);set_tris_b(0);set_tris_c(0);set_tris_d(0);set_tris_e(0);
fprintf(DEBUG,"\n\r");
fprintf(DEBUG,"STARTING\n\r");
P_PB[0].total_cont=0; //set all to zero
P_PB[1].total_cont=0;
P_PB[2].total_cont=0;
P_PB[0].bit_a=0;
P_PB[1].bit_a=0;
P_PB[2].bit_a=0;
Byte_validoB=0;
c=0;
for(c=0;c<3;c++){
fprintf(DEBUG,"Byte_validoB=%u c=%u->",Byte_validoB,c);
P_PB[c].total_cont=4;CNT_db=3; //4>3 to get into if statement
if (P_PB[c].total_cont >= CNT_db){
//P_PB[c].total_cont = CNT_db;
P_PB[c].bit_a = TRUE; //set to true to get else statment
if (P_PB[c].bit_a == FALSE){
//bit_clear(Byte_validoB,c);
}
else{
bit_set(Byte_validoB,c); //set bit 4 of Byte_validoB
fprintf(DEBUG,".");//to let me know that i did bit_set
}
}
fprintf(DEBUG,"Byte_validoB=%u\n\r",Byte_validoB);
}
while (TRUE){
}
}
| I'm giving up. Your not giving me any info to solve your problem. |
|
|
agrj
Joined: 26 Sep 2003 Posts: 48
|
|
Posted: Fri Mar 31, 2006 6:47 am |
|
|
Sorry,
I will try to give you as much information as I can. but I don't know why it is not working here.
the 'c' value is an int and it is incremented like c++.
even though, thanks a lot for your help. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Mar 31, 2006 11:50 am |
|
|
Quote: |
the 'c' value is an int and it is incremented like c++.
|
You defined
int8 Byte_validoB
so bit 'c' can�t be bigger than 7
while if you define:
int32 Byte_validoB
bit 'c' can be as big as 31
In CCS an int is 8 bit wide.
Humberto |
|
|
|
|
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
|