Autor Tema: Error Logic contention detected on net #00023  (Leído 2450 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado claudiovega

  • PIC10
  • *
  • Mensajes: 31
Error Logic contention detected on net #00023
« en: 19 de Agosto de 2016, 13:45:18 »
Estimados: al simular en proteus un programa me da el error indicado en el titulo. El error se produce en la linea punteada de rojo en la imagen adjunta (diagrama proteus). Esta linea es el RX (pin C7) y el error se produce cuando escribo un mensaje desde la consola virtual conectada al max487 (U2), el cual debe viajar hacia el PIC, activar la interrupción y luego retransmitirse a la otra consola virtual.
 
Datos generales:
PIC: 18F2550
Compilador: CCS versión 4

Programa:
Código: [Seleccionar]
#include <18F2550.h>
#use delay(internal = 4000000)
#define use_portb_lcd true
#include <lcd.c>
#fuses INTRC,MCLR,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOCPD
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, STREAM=SENSOR, parity=N, bits=8)
#use rs232(baud=9600, xmit=PIN_C1, rcv=PIN_C2, STREAM=SCREEN, parity=N, bits=8)
// 01 06 77 B0 00 01 52 59
const char start1[9] = {1,6,119,176,0,1,82,89};
const char oxmgl1[9] = {1,3,242,176,0,2,247,84};
const char satur1[9] = {1,3,243,48,0,2,247,64};
const char temp1[9]  = {1,3,125,0,0,2,220,103};
const char stop1[9]  = {1,6,120,48,0,1,80,165};
const char start2[9] = {2,6,119,176,0,1,82,106};
const char oxmgl2[9] = {2,3,242,176,0,2,247,103};
const char satur2[9] = {2,3,243,48,0,2,247,115};
const char temp2[9]  = {2,3,125,0,0,2,220,84};
const char stop2[9]  = {2,6,120,48,0,1,80,150};
const char start3[9] = {3,6,119,176,0,1,83,187};
const char oxmgl3[9] = {3,3,242,176,0,2,246,182};
const char satur3[9] = {3,3,243,48,0,2,246,162};
const char temp3[9]  = {3,3,125,0,0,2,221,133};
const char stop3[9]  = {3,6,120,48,0,1,81,71};
char p, response[13] = "";
int k = 0, i = 0, seconds = 0, contador = 0;
int1 newresponse = 0, wait = 1;
#int_TIMER1                               
void TIMER1_isr(){             
contador++;
if(contador == 2){
seconds++;
contador = 0;
}          
set_timer1(3036);
}
#INT_RDA
void usart_rs485(void)

p = fgetc(SENSOR);
if(p == '\r') {
response[k] = '\0';
newresponse = 1;
k = 0;
}else if(p){
response[k] = p;
k++;
}
}
//funciones 485
#define TX_485_ENABLE PIN_C0
void USART_activa_tx(void){
  output_high(TX_485_ENABLE);
  delay_ms(5);
}
void USART_activa_rx(void){
  delay_ms(5);
  output_low(TX_485_ENABLE);
  delay_ms(1);
}
//funciones de lectura del sensor
void send_command(int id, int action){
char command[9] = "";
if(id == 1){
switch(action){
case 1:
strcpy(command, start1);
break;
case 2:
strcpy(command, oxmgl1);
break;
case 3:
strcpy(command, satur1);
break;
case 4:
strcpy(command, temp1);
break;
case 5:
strcpy(command, stop1);
break;
}
}else if(id == 2){
switch(action){
case 1:
strcpy(command, start2);
break;
case 2:
strcpy(command, oxmgl2);
break;
case 3:
strcpy(command, satur2);
break;
case 4:
strcpy(command, temp2);
break;
case 5:
strcpy(command, stop2);
break;
}
}else if(id == 3){
switch(action){
case 1:
strcpy(command, start3);
break;
case 2:
strcpy(command, oxmgl3);
break;
case 3:
strcpy(command, satur3);
break;
case 4:
strcpy(command, temp3);
break;
case 5:
strcpy(command, stop3);
break;
}
}
USART_activa_tx();
printf("Comando\n");
USART_activa_rx();
}
void read_sensor(int id){
send_command(id, 1);
wait = 1;
while(wait){
if(newresponse){
fprintf(SCREEN, "%s", response);
send_command(id, 2);
newresponse = 0;
wait = 0;
seconds = 0;
}else if(seconds > 5){
fprintf(SCREEN, "No response\r");
send_command(id, 1);
seconds = 0;
}
}
}
//funciones de manejo de la energia
void power_on(){
output_bit(PIN_C5, 1);
}
void power_off(){
output_bit(PIN_C5, 0);
}
//programa principal
void main()
{
lcd_init();

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DISABLED, 0, 1);

enable_interrupts(INT_TIMER1);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
set_timer1(3036);

printf(LCD_PUTC, "\f");
lcd_gotoxy(1,1);
printf(LCD_PUTC, "Hola ^_^");

fprintf(SCREEN, "Start...\r");

while(TRUE)
{
read_sensor(1);
read_sensor(2);
read_sensor(3);
}
}

Mi pregunta es si hay algún error en el programa o en el diagrama en proteus.

Desconectado claudiovega

  • PIC10
  • *
  • Mensajes: 31
Re:Error Logic contention detected on net #00023
« Respuesta #1 en: 19 de Agosto de 2016, 17:25:34 »
He comentado la linea: setup_spi(SPI_SS_DISABLED); y ahora funciona. Si alguien quiere, que me explique por que  :D.


 

anything