CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Code won't run unless programmer is connected

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Code won't run unless programmer is connected
PostPosted: Wed Nov 10, 2004 10:58 am     Reply with quote

Hi all,

I have a question. I am writing some code that uses the RS232 port of a 16F874 to listen for characters on an RS485 bus, and forward them onto an RS232 port. The RS485 uses the hardware UART of my PIC, and the RS232 uses a software UART.

The code works great when I have my IDC-U40 connected, but stops as soon as I disconnect it!

As a test I just want to write to the RS232 as below:

Code:

void main()
{
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);

   while(true)
   {
      fprintf(RS232_STREAM, "A");
      delay_ms(200);
    }
}


This code runs as long as the IDC-40U is plugged in. It stops as soon as it is removed.

If I replace the code as follows:

Code:

void main()
{
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);

   while(true)
   {
      output_high(pin_c2);
      delay_ms(100);
      output_low(pin_c2);
      delay_ms(100);
   }
}


then PIN_C2 flashes away with the IDC plugged in or removed!!!!

Does anyone have any ideas about why this might be so?

I am using V3.207 with a 22K resistor between !MCLR and Vcc.

Many thanks,

Jason
Guest








PostPosted: Wed Nov 10, 2004 11:34 am     Reply with quote

Disable debug in the fuses
Ttelmah
Guest







PostPosted: Wed Nov 10, 2004 11:38 am     Reply with quote

May not be the answer, but what is connected to the hardware serial input line?. Remember that serial data, at 5v (which is what you have at the processor), 'idles high'. If the RS232 input is floating low, then a receive interrupt will be generated, and unless you are accepting the character (you show no receive code), one byte time latter on the UART, there will be a second interrupt, and an overrun error, hanging the UART. I'd suspect that the ICD, is affecting the signal levels/connections round here perhaps. What pins are being used for the RS232?. Unless the transmit pin is C2, there will be an obvious signal 'dfference' about the second lot of code.
Are the 'fuses' entries the same for both sets of code?. Otherwise there are obvious possibilities relating to the pins RB6, and RB7, and RB3 (LVP, and ICD connections).

Best Wishes
jamesjl



Joined: 22 Sep 2003
Posts: 52
Location: UK

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Wed Nov 10, 2004 12:49 pm     Reply with quote

Sorry I was logged in at work before (as a guest).

The fuses include NODEBUG so I don't think that is it.

The software UART uses pins C0 and C1 for Tx and Rx respectively. They are connected to a MAX202E and then onto a D9 that has a lead to my PC running a VB app to capture the characters.

In both pieces of code the fuses are set the same.

The hardware serial line (RS485) is connected to a MAX1487 and the code behaves the same whether the bus is connected or not.

Thanks for the help so far. Anyone else got any ideas.

Regards,

Jason.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Nov 10, 2004 3:08 pm     Reply with quote

Two tips:
1) // #device ICD = TRUE in your header.
2) You have enabled only INT_RDA. Check if PIN_C7 still remain HIGH after
you unplugged the ICD.

HTH, Very Happy

Humberto
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Wed Nov 10, 2004 4:27 pm     Reply with quote

This will probably help:

http://www.ccsinfo.com/forum/viewtopic.php?t=20686
Guest








PostPosted: Thu Nov 11, 2004 1:37 am     Reply with quote

Hi all,

thanks for your replies. In the end it was simple to solve, yet difficult to find. My null modem cable had a break in the ground wire and so would only transmit when a common ground was provided through the IDC.

Kind regards to you all,

Jason.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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