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

Input PIN from RF Receiver - PIC16F628A

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



Joined: 02 Feb 2007
Posts: 1
Location: MO, USA

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

Input PIN from RF Receiver - PIC16F628A
PostPosted: Fri Feb 02, 2007 5:23 pm     Reply with quote

Ok, I'm using PIC16F628A and I have a 315Mhz Receiver.

I now have my chip setup to where I can output data thru my serial port with the Max232, works great. I want to be able to change the output based on PIN_B4.

What I was trying to do was take the hot 5 volts and just tap it onto PIN_B4 a few times to see if I can get something besides a hyphen to print to my computer. However what happens is it just stops my chip for about 3 seconds and then it just reboots.

I have a 315Mhz Receiver for picking up RKE (Remote Keyless Entry) and my RKE sends a series of bits 10101001010101111101100101010101 as a code. what I planned on doing was just if it was "high" I would print a 1, if it was low I would print a zero. and just see if I was able to read what my RKE was sending out.

Does anyone know why my chip reboots when I hook up the 5V to PIN_B4; also is my: set_tris_b(0x00010010); //B1,B4 = Input, else Output.. correct? I'm very new to Microchip programming.

Code:

#include "16F628A.h"
#fuses INTRC_IO, PUT, MCLR, WDT, NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_B2, rcv=PIN_B1)

void main()
{
   
   setup_wdt(WDT_2304MS);
   set_uart_speed(9600);
   set_tris_b(0x00010010); //B1,B4 = Input, else Output..
   output_high(PIN_B5);
   printf("-RESTART-");
   while(TRUE)
   {
      printf("-");
      printf(input(PIN_B4));
      delay_ms(10);
      restart_wdt();
   }
}


edit: what does: input(PIN_B4); return? what data type?
-SpeedyDog
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 02, 2007 5:41 pm     Reply with quote

The default state for pin B4 is to be the PGM pin. See the pinout
in the 16F628A data sheet. If that pin goes to a logic level, the
PIC will go into Low Voltage Programming mode. It will lock up.

Solution:
Add NOLVP to your #fuses statement.

Do this in all of your programs. (Not every PIC supports LVP mode,
but a lot of them do, and it's essential to use NOLVP).


Also, you don't have to set the TRIS. Just use standard i/o mode.
Then the compiler takes care of setting the TRIS for you, if you use
CCS i/o functions (which you are doing). Standard i/o mode is the
default mode of the compiler. You don't have to specify it.
In other words, delete the set_tris_b() statement.
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