ceibawx
Junior Member level 2
- Joined
- Oct 13, 2008
- Messages
- 24
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- chongqing,China
- Activity points
- 1,606
shift_left pic16f8
What's the maximum input bitstream speed in PIC16F877?
My aim is 256kbps. but I failed.
There are results, but I don't understand.Using different output function ways, input speed maximum is not the same? Why?
Any information is appreciated.
----------------------------------------------------------------------------------
pic oscillator frequency is 20MHz. Input clock is the same frequency of input bitstream speed.Instance, input is 256kbps, and input clock is 256khz.
Input bitstream is replaced by function generator output square wave.
(1) input bitstream maximum value is 90kbps when using output_bit() to test output.
output_bit test code.
----------------------------
#include <16F877.h>
#include
#include
#include
#define GP0 PIN_C0 // CLOCK KHz
#define GP1 PIN_C1 //DATA Kbps
#define GP2 PIN_C2 //DATA OUTPUT_BIT
#define GP3 PIN_C6 // RS232 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];
int i;
write_eeprom(10011000,6);
while(TRUE)
{
for (i=0;i<80;i++)
{
while (!input(GP0)); // input clock
eeg=input(GP1); //record bit input
output_bit(GP2,eeg); //test bit output
while (input(GP0)==1);
}
}
}
(2) input bitstream maximum value is 120kbps when using putc() to test output.
#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);
}
}
}
What's the maximum input bitstream speed in PIC16F877?
My aim is 256kbps. but I failed.
There are results, but I don't understand.Using different output function ways, input speed maximum is not the same? Why?
Any information is appreciated.
----------------------------------------------------------------------------------
pic oscillator frequency is 20MHz. Input clock is the same frequency of input bitstream speed.Instance, input is 256kbps, and input clock is 256khz.
Input bitstream is replaced by function generator output square wave.
(1) input bitstream maximum value is 90kbps when using output_bit() to test output.
output_bit test code.
----------------------------
#include <16F877.h>
#include
#include
#include
#define GP0 PIN_C0 // CLOCK KHz
#define GP1 PIN_C1 //DATA Kbps
#define GP2 PIN_C2 //DATA OUTPUT_BIT
#define GP3 PIN_C6 // RS232 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];
int i;
write_eeprom(10011000,6);
while(TRUE)
{
for (i=0;i<80;i++)
{
while (!input(GP0)); // input clock
eeg=input(GP1); //record bit input
output_bit(GP2,eeg); //test bit output
while (input(GP0)==1);
}
}
}
(2) input bitstream maximum value is 120kbps when using putc() to test output.
#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);
}
}
}