Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
LinkBack Thread Tools Display Modes
Old 7th August 2008, 02:59 AM   (permalink)
Default USB with EUSART transmission

Hi!
I am trying to send some data to PIC18F87J50 via EUSART and then transimnit the data to computer via USB.

The USB program I am using is Microchip USB firmware framework v2.2 USB keyboard prgram. and I write the EUSART function myself.
The two EUSART function is pasted below. I put EUSART_config_1() function in the main function before the while(1) loop and put the receiving_1() in the keyboard() function within the if condition
if(!HIDTxHandleBusy(lastTransmission)) so that if the received data is what I want I will transmit the data to computer like pressing a key. However the problem I am facing is that the EUSART seems cannot receive any data even I tried to continously receive 50 times.
Could any one tell me what step I need to add to implement the feature?



unsigned char receiving_1(void)
{
unsigned char tempx = 0;
//PIE1bits.RC1IE = 1; //enable interrupts
RCSTA1bits.SPEN = 1; // serial port enable
RCSTA1bits.SREN = 1; // serial port enable
RCSTA1bits.CREN = 1; // enable receiver
BAUDCON1bits.RCIDL = 1; // receiving operation is active
while(!PIR1bits.RC1IF) {}
tempx = RCREG1;
BAUDCON1bits.RCIDL = 0; // receiving operation is idle
RCSTA1bits.SPEN = 0; // serial port disable
RCSTA1bits.SREN = 0; // serial port enable
RCSTA1bits.CREN = 0; // disable receiver


//PIE1bits.RC1IE = 0; //disable interrupts
return tempx;
}

void EUSART_config_1(void)
{
TRISC |= 0b10000000;
//TRISG |= 0b00000100;
// RCSTA1bits.SPEN = 1;
//RCSTA2bits.SPEN = 1;
TXSTA1 = 0b00000100; //bit7_CSRC: don't care
//bit6_TX9: selects 8-bit transmission
//bit5_TXEN: transmit disable
//bit4_SYNC: Asynchronous mode
//bit3_SENDB: Sync Break transmission complete
//bit2_BRGH: high speed
//bit1_TRMT*: TSR full
//bit0_TX9D: disable 9th bit transmist data

RCSTA1 = 0b00000000; //bit7_SPEN: serial port disabled
//bit6_RX9: selects 8-bit reception
//bit5_SREN: don't care
//bit4_CREN: disable reveiver
//bit3_ADDEN: disables address detection
//bit2_FERR*: no framing error
//bit1_OERR*: overrun error
//bit0_RX8D: disable 9th bit of received data(useless)

BAUDCON1 = 0b00010000;//bit7_ABDOVF: no BRG rollover has occurred
//bit6_RCIDL*: receieve operation is idle
//bit5_DTRXP: receive data is not inverted
//bit4_SCKP:idle state for transmit is a low level
//bit3_BRG16: 8-bit baud rate generator-SPBRG1 only
//bit2: unimplemented
//bit1_WUE: RX1 pin is not monitored or rsing edge detected
//bit0_ABDEN: baud rate measurement disabled or completed
SPBRG1 = 77; //baud rate set to 9600 for 12MHz, high speed
}
jonathan_hank is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Power Transmission ebuka_2 Electronic Projects Design/Ideas/Reviews 9 13th May 2008 05:10 PM
PIC 18f1220 EUSART Baud Rate Cache Problem wklose99 Micro Controllers 7 16th April 2008 11:37 PM
EUSART issues richb Micro Controllers 3 21st March 2008 03:26 AM
IR transmission mayassn General Electronics Chat 3 14th February 2008 02:56 AM
RF Transmission Hicks_Man General Electronics Chat 4 4th March 2006 08:59 PM



All times are GMT. The time now is 09:07 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker