Huy guys (and girls)
I have two questions
1.
I'm trying to make pic16f690 recive bytes on pin 19 RAO and send bytes on pin 10 RB7,
I have red that I need to make pins digital and also define them as in or out pins, If I'm not mistaking I need to put "set_trisx(...) somewhere?
2. How do I set the internal oscillator
I'm thinking if this is correct, and does this mean that I don't need any external xrstal?
but I don't know if it's correct.
Here is my code
I've bin trying to figure this out for 3 days now, any help would be extremly appriciated.
Regards
I have two questions
1.
I'm trying to make pic16f690 recive bytes on pin 19 RAO and send bytes on pin 10 RB7,
I have red that I need to make pins digital and also define them as in or out pins, If I'm not mistaking I need to put "set_trisx(...) somewhere?
2. How do I set the internal oscillator
I'm thinking if this is correct, and does this mean that I don't need any external xrstal?
Rich (BB code):
#FUSE INTRC and
#Delay (clock=...)
Here is my code
Rich (BB code):
#include <16F690.h>
#fuses NOWDT,HS,NOPUT,NOPROTECT
#use delay(clock=8000000)
#use rs232(baud=2400,parity=N,xmit=PIN_B7,rcv=PIN_B5,bits=9)
void clockwait(void);
void main()
{
unsigned char byt; // Holds each byte received
unsigned char t; // Variable t declaration
setup_counters(RTCC_INTERNAL,RTCC_DIV_1);
while(1) // Loop forever...
{
byt=0; // Starting a new data frame
clockwait(); // Ignore start bit
for(t=0;t<8;t++) // Grab eight bits of data...
{
clockwait();
byt|=input(PIN_A0)<<t;
}
clockwait(); // Ignore parity bit
clockwait(); // Ignore stop bit
putc(byt); // Send byte to the transmitter
} // ... rinse and repeat :)
}
void clockwait(void)
{
// Waits for the next clock cycle...
while(!input(PIN_A1)); // Wait for clock to go HI
while(input(PIN_A1)); // Wait for clock to go LO
}
I've bin trying to figure this out for 3 days now, any help would be extremly appriciated.
Regards