|
|
View previous topic :: View next topic |
Author |
Message |
SpeedyDog
Joined: 02 Feb 2007 Posts: 1 Location: MO, USA
|
Input PIN from RF Receiver - PIC16F628A |
Posted: Fri Feb 02, 2007 5:23 pm |
|
|
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
|
|
Posted: Fri Feb 02, 2007 5:41 pm |
|
|
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. |
|
|
|
|
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
|