Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/04/09 19:58
Modified:
  11/04/09 20:23

Read: times


 
#170446 - Here ya go...
Responding to: ???'s previous message
code=filename.txt]include <Philips8xC31-51-80C51Fx-80C51Rx+.h>
#include <standard.h>
#define PORT1 P1 // P1 recieves the ADC data and transfers it to serial port //
unsigned char mybyte ; //intermediate variable//
void serial_send(unsigned char mybyte ) ;
void main (void)
{ TMOD = 0x20;
SCON = 0x50;
TH1 = 0xFD;
TR1 = 1 ;
TI = 0 ;
while(1)
{ mybyte = PORT1 ; // from port 1 to mybyte variable //
serial_send(mybyte) ;
}
}
void serial_send(unsigned char mybyte)
{ SBUF = mybyte ;
while(TI) <------- Shouldn't there be a semi-colon?
TI = 0 ;
}
  Also, how come you dont have a specific interrupt that the compiler understands.... like in KEIL here is an example:
void it_UART(void) interrupt IRQ_UART // shows the interrupt and IRQ_UART is the number given in the .h file

{
if(RI) // If reception occurs
{
RI = 0; // Clear reception flag for next receptoin
if (UART_INDEX < MAX_UART_BUFF)
{
UART_DATA[UART_INDEX] = SBUF; // Read receive data
UART_INDEX++;
}
else
{
SIOERROR = 1;
}
}
else
{
TI = 0; // If emission occured, clear emission flag
CLRTI = 1;
}
}  
On top of that do you have your baud set properly? Which is highly dependent on what processor youre using and this isnt copiable.
void UART_Init(void)

{
Set_uart_x1_mode(); // UART is in X1 Mode
SCON = 0x50; // UART in mode 1 (8 bit), REN = 1 (ENABLE RECEPTION)
BDRCON &= 0xEE; // BRR = 0 (BAUD RATE GENERATOR NOT RUNNING); SRC = 0 (Set if using MODE1 for IBRG);
BDRCON |= 0x0C; // TBCK = 1 (USE IBRG); RBCK = 1 (USE IBRG); SPD = 1 (USED TO CALC BAUD);
PCON |= 0x80; // SMOD1 = 1 (USED TO CALC BAUD), SMOD0 = 0 (USED TO SELECT SM0)
BRL = 0xF3; // 19200 Bds with 48MHz OSCILLATOR, X1 mode, SPD = 0, SMOD1 = 1
ES = 1; // Enable Serial Interrupt
BDRCON |= 0x10; // Baud rate generator run
}  


List of 5 messages in thread
TopicAuthorDate
URGENT !!! 8051 SERIAL COMMUNICATION CODE HELP            01/01/70 00:00      
   Duplicate Thread!            01/01/70 00:00      
      Not exactly ...            01/01/70 00:00      
   TI            01/01/70 00:00      
   Here ya go...            01/01/70 00:00      

Back to Subject List