SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By ceibawx
#58404
Another question.
In project 256kbps input bitstream is needed. However Now input speed only 120kbps is allowed in circuit.
How can I slove it ?
*change baud rate setting for asynchronous in PIC?
Now default baud as 312.5k is used. Shall we change it into high speed. set BRGH=1, then baud rate is 1250k under 20MHz clock.
*Change PIC? Now it is pic16f877. Now I used its default baud,it should be 312.5k under 20MHz clock.
*Use assembly language ?
*Other ways?

Which is helpful?

-------------------------

#include <16F877.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define GP0 PIN_C0 // CLOCK 64KHZ
#define GP1 PIN_C1 //DATA 64KBAUD
#define GP2 PIN_C2 //DATA OUTPUT
#define GP3 PIN_C6 //UART OUTPUT

#use delay(clock=20000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, parity=N, bits=8, stream=TXBEE)


void main()
{
int eeg[80],b;
int i,j,k;

while(TRUE)
{
int8 in_bits[10]; //only 10 bytes in memory, one bit per bit

//recieve 80 bits stream
for (i=0;i<80;i++)
{
while (input(GP0)==0); //{}
shift_left(in_bits, 10, input(GP1)); //see help for shift_left function
while (input(GP0)==1); // {}
}

//then send it
for (i=0;i<10;i++)
{
putc(in_bits);
output_toggle(PIN_C4);
delay_us(100);
output_toggle(PIN_C4);
}