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 CCS Technical Support

Strange I/O Behaviour.....

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








Strange I/O Behaviour.....
PostPosted: Tue Dec 19, 2006 5:09 pm     Reply with quote

Hi,

I have a project that uses a couple of pushbuttons connected to individual I/O pins. I recently changed from a 16F628 to a 16F819 because I needed an A/D channel, but now one of my buttons is not working properly. I have reduced the problem to a simple test program shown below:

Code:

#include <16f628.h>
#fuses XT, NOWDT, NOPROTECT, NOLVP, BROWNOUT

//-----< Compiler use statements >-----

// Tell compiler clock speed is 4.00 MHZ Crystal
#use delay(clock=4000000)

//-----< General Program Defines >-----
#define Tx_Out PIN_B3         // serial data transmit pin to PC
#define Inc_Btn PIN_A3         // Increment button
#define Dec_Btn PIN_B5         // Decrement button

//-----< Serial Port Definition >-----
#use rs232(baud=9600, xmit=Tx_Out)

void main(void)
{
   printf("At the top... \n\r");
   
   while(1)
   {
         if (!input(Inc_Btn))
         {
            delay_ms(150);
            printf("Incrementing\n\r");
            while (!input(Inc_Btn));
         }

         if (!input(Dec_Btn))
         {
            delay_ms(150);
            printf("Decrementing\n\r");
            while (!input(Dec_Btn));
         }
                        
   } // while

} // end Main


When I run this code using a 16F628 it works as expected, and I see the following on HyperTerminal:

At the top...
Incrementing <---- Increment Button Pushed
Decrementing <---- Decrement Button Pushed

When I run this code using a 16F819 it does not work as expected, and I see the following on HyperTerminal:

At the top...
At the top...
Incrementing <---- Increment Button Pushed
Decrementing <---- Decrement Button Pushed

Notice that when the Increment button is pushed, the code seems to restart from the top, but this does not happen with the Decrement button.

Is something associated with input pin A3 causing this to happen on the 16F819? If so, I can't figure it out!

Compiler is 3.249

Thanks,

Charlie
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 19, 2006 5:48 pm     Reply with quote

The 16F819 has a lot of flaky erratas on the i/o pins.

A4 silicon errata:
http://ww1.microchip.com/downloads/en/DeviceDoc/80159f.pdf

B0 silicon errata:
http://ww1.microchip.com/downloads/en/DeviceDoc/80212c.pdf

I looked at the .LST file code, and it's setting up Port A as all digital.
That part is correct.

On the A4 errata, where the chip resets if you do almost anything
to the PGM pin (pin B3) -- this could be the problem.

Try using a different pin for your RS232 output. Configure pin RB3
to be a high-level output pin. Make sure the NOLVP fuse is enabled.
Code:
output_high(PIN_B3);

This would help to tell if the problem is due to the pin B3 errata.

The ports on this PIC are still so flaky, even with the B0 errata, that
I would just go use another chip.
Guest








PostPosted: Wed Dec 20, 2006 7:26 pm     Reply with quote

Hi PCM,

Thanks for the reply! I moved the Tx to another pin and set B3 high as you suggested, but no luck on solving the problem Sad I then moved my 'Increment' pushbutton to a different pin, and that solved the problem Very Happy !

I'll probably change chips for the final version of my project, but at least these changes will allow me to continue coding until I can do that!

Thanks again!

Charlie
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