|
|
View previous topic :: View next topic |
Author |
Message |
rodrigocirilo
Joined: 14 Sep 2016 Posts: 20
|
16F648A UART problem |
Posted: Thu May 21, 2020 12:38 pm |
|
|
Hello my dear.
I'm having a problem here, I'm using the serial software on pic 16f648a for physical reasons of the PCB, so I used pin A4 as TX and pin A2 as RX, and it just doesn't work. both real and virtual.
If I do an inversion of pins A2 as TX and A4 as RX it works immediately.
In fact, when set up the first way, he receives what comes through the RX, and then I send him through the TX and he won't.
I mess around with serials on other pic's, but this problem is killing me.
Since both pins are bi-directional, why does A4 not work as TX?
Code: |
#include <16F628A.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#use delay(clock=4000000)
#use rs232(baud=1200,xmit=PIN_A4,rcv=PIN_A2,bits=8,parity=N)//,errors)//RS485//enable=PIN_A3
char buffer;
unsigned int32 digito = 1012345;
char mystring[8];
void main()
{
set_tris_a(0b11100111);
while(true)
{
if (kbhit () == 1)
{
buffer = getc ();
if(buffer == 'a')
{
output_high(pin_A1);
delay_ms(100);
output_low(pin_A1);
delay_ms(100);
sprintf(mystring,"%lu",digito);
puts(mystring);
}
}
}
} |
Please help
Editing:
Is it because despite being bi-directional the pins in question, A2 is CMOS so it works like TX and RX and A4 is open Drain and only works like RX |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19505
|
|
Posted: Thu May 21, 2020 1:12 pm |
|
|
A4, will work, but you would need to supply an external pull-up resistor.
Something like a 2K2 resistor between the pin and 5v. Without this, there
is nothing to take the signal high.... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Thu May 21, 2020 4:58 pm |
|
|
Also, you're using a software UART not a hardware UART by using those pins, so the PIC will 'bitbang' the pins. Unless you use fancy software, you can't use interrupts or do anything while transmitting or receving data.
That PIC does have a HW UART and you should use it if at all possible. |
|
|
rodrigocirilo
Joined: 14 Sep 2016 Posts: 20
|
|
Posted: Fri May 22, 2020 5:19 am |
|
|
Ttelmah wrote: | A4, will work, but you would need to supply an external pull-up resistor.
Something like a 2K2 resistor between the pin and 5v. Without this, there
is nothing to take the signal high.... |
Thanks, I had just found this solution elsewhere and it worked.
now i will enable the enable pin and try on RS485, which is my final target. |
|
|
rodrigocirilo
Joined: 14 Sep 2016 Posts: 20
|
|
Posted: Fri May 22, 2020 5:20 am |
|
|
temtronic wrote: | Also, you're using a software UART not a hardware UART by using those pins, so the PIC will 'bitbang' the pins. Unless you use fancy software, you can't use interrupts or do anything while transmitting or receving data.
That PIC does have a HW UART and you should use it if at all possible. |
in this case for a physical matter of pin placement I was forced to use uart Software, but thanks for the tip. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Fri May 22, 2020 6:50 am |
|
|
For your next project, connect 2 pads to each I/O pin and the 'stuff' it controls. If you have a thin trace between the pads, you can cut it, then use soild wire jumpers to redirect the I/O pins.
So
pic pin5<--->pad1<--->pad2<---->stuff
pic pin6<--->pad3<--->pad4<---->stuff
cut the trace between pad1 and pad2.
cut the trace between pad3 and pad4.
solder jumpers
between pad1 and pad4
between pad3 and pad2
That 'swaps' the pin uses.
Hope this is clear to understand.
This is real handy if you get the PIC USB +D, -D pins 'reversed' going to the USB connector........sigh, BTDT....
Other trap is having TXD and RXD reversed (TXD to TXD, RXD to RXD).
While this 'double pad' system will increase the PCB area a little, it does allow flexability and EASY repairs as no new PCB is required.
Jay |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Fri May 22, 2020 12:27 pm |
|
|
rodrigocirilo wrote: | in this case for a physical matter of pin placement I was forced to use uart Software, but thanks for the tip. |
Ummm, it's more than just a 'tip'!
Unless your program is really simple, you'll move 'heaven and earth' in order to take advantage of the hardware UART on any PIC you are using. Seriously, whatever you need to do, it's probably worth it! _________________ John
If it's worth doing, it's worth doing in real hardware! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19505
|
|
Posted: Fri May 22, 2020 12:50 pm |
|
|
Lets just list the problems of the standard software UART:
1) Half duplex only. Can only transmit or receive, not both at the same
time.
2) Has to be called before the character actually arrives. You have to be
sitting waiting for a character to arrive. This also implies it can't buffer
incoming data.
3) Will be adversely affected if any interrupts are in use.
For a basic simple transmission it can usually work OK. For reception
it will give problems.
I have posted in the past a receive using a timer interrupt, which for
reasonable baud rates is a better solution for the receive.
<http://www.ccsinfo.com/forum/viewtopic.php?t=51403&highlight=timer+interrupt+serial+recieve+receive> |
|
|
rodrigocirilo
Joined: 14 Sep 2016 Posts: 20
|
|
Posted: Sun May 24, 2020 7:23 am |
|
|
temtronic wrote: | For your next project, connect 2 pads to each I/O pin and the 'stuff' it controls. If you have a thin trace between the pads, you can cut it, then use soild wire jumpers to redirect the I/O pins.
So
pic pin5<--->pad1<--->pad2<---->stuff
pic pin6<--->pad3<--->pad4<---->stuff
cut the trace between pad1 and pad2.
cut the trace between pad3 and pad4.
solder jumpers
between pad1 and pad4
between pad3 and pad2
That 'swaps' the pin uses.
Hope this is clear to understand.
This is real handy if you get the PIC USB +D, -D pins 'reversed' going to the USB connector........sigh, BTDT....
Other trap is having TXD and RXD reversed (TXD to TXD, RXD to RXD).
While this 'double pad' system will increase the PCB area a little, it does allow flexability and EASY repairs as no new PCB is required.
Jay |
Thanks for that, I will try to do that on my next pcb's.
The problem I face is, I get a commercial keyboard ready, it contains a uC Holtek (which I don't know how to program and I don't have the recorder) it has 14 SMD pins. So the pic that fits perfectly on the site is 16f688 (I love this pic) so it suits me, but I had to migrate to an auxiliary pcb and would use the 16f648, but I gave up for the problems I had.
On the 688 I lacked a pin, so I decided to put the MAX485 enable together with the base of the BUZZER transistor, when I need it, I play the buzzer, and when I need to send data the buzzer gives a small whistle (no problem for me)
so I haven't used serial hardware since the beginning. |
|
|
rodrigocirilo
Joined: 14 Sep 2016 Posts: 20
|
|
Posted: Sun May 24, 2020 7:25 am |
|
|
ezflyr wrote: | rodrigocirilo wrote: | in this case for a physical matter of pin placement I was forced to use uart Software, but thanks for the tip. |
Ummm, it's more than just a 'tip'!
Unless your program is really simple, you'll move 'heaven and earth' in order to take advantage of the hardware UART on any PIC you are using. Seriously, whatever you need to do, it's probably worth it! |
whenever I can I prefer serial hardware, serial software is only when the whole thing is ready. |
|
|
rodrigocirilo
Joined: 14 Sep 2016 Posts: 20
|
|
Posted: Sun May 24, 2020 7:26 am |
|
|
Ttelmah wrote: | Lets just list the problems of the standard software UART:
1) Half duplex only. Can only transmit or receive, not both at the same
time.
2) Has to be called before the character actually arrives. You have to be
sitting waiting for a character to arrive. This also implies it can't buffer
incoming data.
3) Will be adversely affected if any interrupts are in use.
For a basic simple transmission it can usually work OK. For reception
it will give problems.
I have posted in the past a receive using a timer interrupt, which for
reasonable baud rates is a better solution for the receive.
<http://www.ccsinfo.com/forum/viewtopic.php?t=51403&highlight=timer+interrupt+serial+recieve+receive> |
Thank you very much for these considerations. |
|
|
rodrigocirilo
Joined: 14 Sep 2016 Posts: 20
|
|
Posted: Sun May 24, 2020 7:34 am |
|
|
Now I'm back to pic 16F688, everything is going well in real / virtual.
But one thing is puzzling me.
The flag_emergencia variable starts with a value of 0, so I receive a keep alive via serial to keep this variable with a value of 0, if I don't receive it, the timer counts until a counter overflows that makes this variable 1.
My problem is: Even if the variable flag_emergencia is 0, when the function sends () at this very moment it becomes value 1 and ends up in the first if that compares if it really has value 1, but this should not occur, it should have a value of 1 only if reset_contador overflows the value. How is it possible for the variable to change value alone ??
Code: |
//16f688
// VCC-| |-GND
// RELE A5-| |-A0 - DATA - SENSOR
//BUZZER E ENABLE A4-| |-A1 - CLOCK - TX
// RX A3-MCLR-| |-A2
// C5-| |-C0
// C4-| |-C1
// C3-| |-C2
#include <16F688.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOCPD //No EE protection
#FUSES PUT //Power Up Timer
#FUSES NOIESO //Internal External switch Over mode disabled
#FUSES RESERVED //Used to set the reserved FUSE bits
#use delay(clock=4000000)
#use rs232(baud=1200,parity=N,xmit=PIN_A1,rcv=PIN_A3,enable=PIN_A4,bits=8)//RS485//,enable=PIN_A5
int tempo=200;
int flag=0;
int flag1=0;
int b = 0;
int c = 0;
unsigned int32 digito=0;
char buffer[6];
char idd[2];
char sensor[7];
char pedido[7];
char mystring[6];
char ID_mystring[9];
int1 flag_sensor = false;
int flag_emergencia = 0;
unsigned int flag_digito4ou6 = 0;
unsigned int contador=0;
unsigned int reset_contador = 0;
unsigned int ID = 0;
unsigned int a=0;
unsigned int x=0 ;
void bipa();
void envia();
void bipa_limpa(void);
void bip_ok(void);
void bip_erro(void);
void seta_ID(void);
void bipa_limpa(void)
{
restart_wdt () ;
output_high (PIN_A4) ;
delay_ms (20) ;
output_low (PIN_A4);
delay_ms (20) ;
output_high (PIN_A4) ;
delay_ms (20) ;
output_low (PIN_A4);
delay_ms (20) ;
}
void bip_erro(void)
{
restart_wdt () ;
output_high (PIN_A4) ;
delay_ms (1000) ;
output_low (PIN_A4);
restart_wdt () ;
}
void bip_ok(void)
{
restart_wdt () ;
output_high (PIN_A4) ;
delay_ms (30) ;
output_low (PIN_A4);
delay_ms (30);
output_high (PIN_A4) ;
delay_ms (30) ;
output_low (PIN_A4);
delay_ms (30) ;
output_high (PIN_A4) ;
delay_ms (30) ;
output_low (PIN_A4);
delay_ms (30) ;
}
void bipa(void)
{
output_high (PIN_A4) ;
delay_ms (50) ;
output_low (PIN_A4);
}
void envia(void)
{
restart_wdt () ;
if(flag_emergencia == 1)
{
output_high(PIN_A5);
delay_ms(500);
output_low(PIN_A5);
digito = 0;
contador = 0;
}
else
{
if(flag_digito4ou6 == 0)
{
digito = digito * 100 + 99;
}
sprintf(mystring,"%lu",digito);
ID_mystring[0] = idd[0];
ID_mystring[1] = idd[1];
ID_mystring[2] = mystring[0];
ID_mystring[3] = mystring[1];
ID_mystring[4] = mystring[2];
ID_mystring[5] = mystring[3];
ID_mystring[6] = mystring[4];
ID_mystring[7] = mystring[5];
printf(ID_mystring);
delay_ms (250);
digito = 0;
mystring [0] = ' ';
mystring [1] = ' ';
mystring [2] = ' ';
mystring [3] = ' ';
mystring [4] = ' ';
mystring [5] = ' ';
ID_mystring[0] = ' ';
ID_mystring[1] = ' ';
ID_mystring[2] = ' ';
ID_mystring[3] = ' ';
ID_mystring[4] = ' ';
ID_mystring[5] = ' ';
ID_mystring[6] = ' ';
ID_mystring[7] = ' ';
contador = 0;
flag_digito4ou6 = read_eeprom(2);
}
}
//#int_TIMER0
//void TIMER0_isr(void)
#int_TIMER1
void TIMER1_isr(void)
{
b++;
if (b == 2)
{
b = 0;
c++;
}
if (c == 120)
{
c = 0;
digito = 0;
a = 0;
}
reset_contador++;
if(reset_contador >= 5) //40
{
// modo emergencia
flag_emergencia = 1;
reset_contador = 0;
}
}
void seta_ID(void)
{
////////////////////////////////////////rotina para programar o ID do teclado////////////////////////////////////////////////////
while (contador >= 80)
{
restart_wdt () ;
output_high (PIN_C0);
output_high (pin_a4) ; // BIPANDO PRA SINALIZAR QUE ESTÁ EM PROGRAMAÇÃO
delay_ms (20) ; // BIPANDO PRA SINALIZAR QUE ESTÁ EM PROGRAMAÇÃO
output_low (pin_a4) ; // BIPANDO PRA SINALIZAR QUE ESTÁ EM PROGRAMAÇÃO
delay_ms (100) ;
////////////////////////////////////leitura do teclado para programar ID do teclado/////////////////////////////////////////////
output_low (PIN_C0); //multiplexação das portas para teclado matricial.
if ( ! input (PIN_A2) )
{
bipa () ;
while ( ! input (PIN_A2) )
{
restart_wdt () ;
}
ID = ID * 10 + 1;
x++;
delay_ms (tempo) ;
}
if ( ! input (PIN_C1) )
{
bipa () ;
while ( ! input (PIN_C1) )
{
restart_wdt () ;
}
ID = ID * 10 + 4;
x++;
delay_ms (tempo) ;
}
if ( ! input (PIN_C2) )
{
bipa () ;
while ( ! input (PIN_C2) )
{
restart_wdt () ;
}
ID = ID * 10 + 7;
x++;
delay_ms (tempo) ;
}
output_high (PIN_C0);
output_low (pin_C4) ;
if ( ! input (PIN_A2) )
{
bipa () ;
while ( ! input (PIN_A2) )
{
restart_wdt () ;
}
ID = ID * 10 + 2;
x++;
delay_ms (tempo) ;
}
if ( ! input (PIN_C1) )
{
bipa () ;
while ( ! input (PIN_C1) )
{
restart_wdt () ;
}
ID = ID * 10 + 5;
x++;
delay_ms (tempo) ;
}
if ( ! input (PIN_C2) )
{
bipa () ;
while ( ! input (PIN_C2) )
{
restart_wdt () ;
}
ID = ID * 10 + 8;
x++;
delay_ms (tempo) ;
}
if ( ! input (PIN_C3) )
{
bipa () ;
while ( ! input (PIN_C3) )
{
restart_wdt () ;
}
if(ID == 0)
{
if(flag_digito4ou6 == 0)
{
flag_digito4ou6 = 1;
write_eeprom(2, 1);
delay_ms(100);
reset_cpu();
contador = 0;
}
else
{
flag_digito4ou6 = 0;
write_eeprom(2, 0);
delay_ms(200);
reset_cpu();
contador = 0;
}
}
else
{
ID = ID * 10;
x++;
}
delay_ms (tempo) ;
}
output_high (pin_C4);
output_low (pin_C5) ;
if ( ! input (PIN_A2) )
{
bipa () ;
while ( ! input (PIN_A2) )
{
restart_wdt () ;
}
ID = ID * 10 + 3;
x++;
delay_ms (tempo) ;
}
if ( ! input (PIN_C1) )
{
bipa () ;
while ( ! input (PIN_C1) )
{
restart_wdt () ;
}
ID = ID * 10 + 6;
x++;
delay_ms (tempo) ;
}
if ( ! input (PIN_C2) )
{
bipa () ;
while ( ! input (PIN_C2) )
{
restart_wdt () ;
}
ID = ID * 10 + 9;
x++;
delay_ms (tempo) ;
}
if ( ! input (PIN_C3)) // digito quadrado limpa
{
bipa_limpa () ;
while ( ! input (PIN_C3) )
{
restart_wdt () ;
}
ID = 0;
x = 0;
delay_ms (tempo) ;
}
output_high (pin_C5) ;
if (x == 2)
{
bip_ok () ;
x = 0;
restart_wdt () ;
write_eeprom(0, ID);
delay_ms(200);
contador = 0;
reset_cpu();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
void main()
{
set_tris_a (0b001101);
set_tris_c(0b001110);
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
// setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
//setup_wdt(WDT_ON);
// setup_wdt(WDT_2304MS);//|WDT_TIMES_32); //~4,6 s reset desliguei por enquato
// enable_interrupts(INT_RTCC);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
setup_comparator (NC_NC_NC_NC) ;
setup_vref (FALSE);
output_low(PIN_A4); // desliga buzer
ID = read_eeprom(0);
if(ID == 255)
{
ID = 0;
}
sprintf(idd,"%u",ID);
flag_digito4ou6 = read_eeprom(2);
/* if(flag_digito4ou6 == 255)
{
flag_digito4ou6 = 0;
write_eeprom(2, 0);
}
*/
while (true)
{
restart_wdt () ;
if (kbhit () == 1)
{
int i;
int counter;
counter++;
buffer[i++]=getc(); // aqui somente recebe o que vem do pc e monta a string
if(counter == 5)
{
//aqui checa o ID
if((buffer[0] == idd[0]) && (buffer[1] == idd[1]) && (buffer[2] == 'O') && (buffer[3] == 'K') && (buffer[4] == 'K')) // recebe keep alive
{
//resetar contador de entrar no modo emergencia
flag_emergencia = 0;
reset_contador=0;
counter = 0;
i = 0;
buffer[0] = ' ';
buffer[1] = ' ';
buffer[2] = ' ';
buffer[3] = ' ';
buffer[4] = ' ';
}
if((buffer[0] == idd[0]) && (buffer[1] == idd[1]) && (buffer[2] == 'O') && (buffer[3] == 'N') && (buffer[4] == 'N')) // abre porta
{
counter = 0;
i = 0;
buffer[0] = ' ';
buffer[1] = ' ';
buffer[2] = ' ';
buffer[3] = ' ';
buffer[4] = ' ';
}
if((buffer[0] == idd[0]) && (buffer[1] == idd[1]) && (buffer[2] == 'N') && (buffer[3] == 'A') && (buffer[4] == 'O')) // senha errada
{
counter = 0;
i = 0;
buffer[0] = ' ';
buffer[1] = ' ';
buffer[2] = ' ';
buffer[3] = ' ';
buffer[4] = ' ';
}
}
if(counter > 5)
{
counter = 0;
i = 0;
buffer[0] = ' ';
buffer[1] = ' ';
buffer[2] = ' ';
buffer[3] = ' ';
buffer[4] = ' ';
}
}
if (flag == 1)
{
bip_ok () ;
flag = 0;
}
if (flag1 == 1)
{
bip_erro ();
flag1 = 0;
}
output_low (PIN_C0); //multiplexação das portas para teclado matricial.
if ( ! input (PIN_A2) )
{
bipa () ;
while ( ! input (PIN_A2) )
{
restart_wdt () ;
}
digito = digito * 10 + 1;
a++;
contador = 0;
delay_ms (tempo) ;
}
if ( ! input (PIN_C1) )
{
bipa () ;
while ( ! input (PIN_C1) )
{
restart_wdt () ;
}
digito = digito * 10 + 4;
a++;
contador = 0;
delay_ms (tempo) ;
}
if ( ! input (PIN_C2) )
{
bipa () ;
while ( ! input (PIN_C2) )
{
restart_wdt () ;
}
digito = digito * 10 + 7;
a++;
contador = 0;
delay_ms (tempo) ;
}
if ( ! input (PIN_C3)) /// tecla P se apartada por 20 segundos entra no modo de seleção de porta 1, 2 ou 3
{ // a tecla 2 porta 1 ======= tecla 5 porta 2 ===== tecla 8 porta 3 === tecla 0 modo segurança
pedido[0] = idd[0];
pedido[1] = idd[1];
pedido[2] = 'A';
pedido[3] = 'B';
pedido[4] = 'R';
pedido[5] = 'E';
printf(pedido);
while ( ! input (PIN_C3) )
{
restart_wdt () ;
contador++;
delay_ms (50) ;
restart_wdt () ;
if(contador >= 80)
{
ID = 0;
seta_ID();
}
}
}
output_high (PIN_C0);
output_low (pin_C4) ;
if ( ! input (PIN_A2) )
{
bipa () ;
while ( ! input (PIN_A2) )
{
restart_wdt () ;
}
digito = digito * 10 + 2;
a++;
contador = 0;
delay_ms (tempo) ;
}
if ( ! input (PIN_C1) )
{
bipa () ;
while ( ! input (PIN_C1) )
{
restart_wdt () ;
}
digito = digito * 10 + 5;
a++;
contador = 0;
delay_ms (tempo) ;
}
if ( ! input (PIN_C2) )
{
bipa () ;
while ( ! input (PIN_C2) )
{
restart_wdt () ;
}
digito = digito * 10 + 8;
a++;
contador = 0;
delay_ms (tempo) ;
}
if ( ! input (PIN_C3) )
{
bipa () ;
while ( ! input (PIN_C3) )
{
restart_wdt () ;
}
digito = digito * 10;
a++;
contador = 0;
delay_ms (tempo) ;
}
output_high (pin_C4);
output_low (pin_C5) ;
if ( ! input (PIN_A2) )
{
bipa () ;
while ( ! input (PIN_A2) )
{
restart_wdt () ;
}
digito = digito * 10 + 3;
a++;
contador = 0;
delay_ms (tempo) ;
}
if ( ! input (PIN_C1) )
{
bipa () ;
while ( ! input (PIN_C1) )
{
restart_wdt () ;
}
digito = digito * 10 + 6;
a++;
contador = 0;
delay_ms (tempo) ;
}
if ( ! input (PIN_C2) )
{
bipa () ;
while ( ! input (PIN_C2) )
{
restart_wdt () ;
}
digito = digito * 10 + 9;
a++;
contador = 0;
delay_ms (tempo) ;
}
if ( ! input (PIN_C3)) // digito quadrado limpa
{
bipa_limpa () ;
while ( ! input (PIN_C3) )
{
restart_wdt () ;
}
digito = 0;
a = 0;
contador = 0;
delay_ms (tempo) ;
}
output_high (pin_C5) ;
if ((a == 4) && (flag_digito4ou6 == 0))
{
bip_ok () ;
a = 0;
restart_wdt () ;
envia () ;
}
if ((a == 6) && (flag_digito4ou6 == 1))
{
bip_ok () ;
a = 0;
restart_wdt () ;
envia () ;
}
//////////////////////////////sensor porta////////////////////////////////////////////
if((!input(PIN_A0)) && (flag_sensor == false)) //porta fechou
{
sensor[0] = idd[0];
sensor[1] = idd[1];
sensor[2] = 'C';
sensor[3] = 'L';
sensor[4] = 'O';
sensor[5] = 'S';
printf(sensor);
delay_ms(250);
flag_sensor = true;
}
if((input(PIN_A0)) && (flag_sensor == true))
{
sensor[0] = idd[0];
sensor[1] = idd[1];
sensor[2] = 'O';
sensor[3] = 'P';
sensor[4] = 'E';
sensor[5] = 'N';
printf(sensor);
delay_ms(250);
flag_sensor = false;
}
//////////////////////////////////////////////////////////////////////////////////////
}
}
|
compiler version 5.015 |
|
|
rodrigocirilo
Joined: 14 Sep 2016 Posts: 20
|
|
Posted: Mon May 25, 2020 1:18 pm |
|
|
someone please help me with the variable changing value alone. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 25, 2020 1:56 pm |
|
|
Is your code that you posted the exact program that you are using
to get the flag_emergencia bug ?
Are you secretly turning on WDT and not telling us ?
Your posted code has it commented out.
Quote: | //setup_wdt(WDT_ON);
// setup_wdt(WDT_2304MS);//|WDT_TIMES_32); //~4,6 s reset desliguei por enquato |
Is it still commented out when you get the flag_emergencia bug ?
----------------------
Another thing I noticed is you have 3 calls to reset_cpu() in your program.
Normally this is not done. My feeling is no wonder your program has
mysterious bugs. Your programming methods are not the best. |
|
|
rodrigocirilo
Joined: 14 Sep 2016 Posts: 20
|
|
Posted: Mon May 25, 2020 2:12 pm |
|
|
PCM programmer wrote: | Is your code that you posted the exact program that you are using
to get the flag_emergencia bug ?
Are you secretly turning on WDT and not telling us ?
Your posted code has it commented out.
Quote: | //setup_wdt(WDT_ON);
// setup_wdt(WDT_2304MS);//|WDT_TIMES_32); //~4,6 s reset desliguei por enquato |
Is it still commented out when you get the flag_emergencia bug ?
----------------------
Another thing I noticed is you have 3 calls to reset_cpu() in your program.
Normally this is not done. My feeling is no wonder your program has
mysterious bugs. Your programming methods are not the best. |
yes, it is the exact program i am using.
Yes it is commented all the time, because I only use WDT after the software is ready and working. |
|
|
|
|
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
|