用PIC18,用示波器看了,是有0x55出来,不知怎么搞的
10MHzFosc,HS-PLL,4所以,40MHz
SYNC = 0, BRGH = 0, BRG16 = 0
void main (void)
{
unsigned char str[10]={1,2,3,4,5,6,7,8,9,0};
/* Make all bits on the Port B (LEDs) output bits.
* If bit is cleared, then the bit is an output bit.
*/
SPBRG2 = 0x19;
TXSTA2 = 0x24;
TRISB = 0;
//delay ();
//禁止发送中断 禁止接收中断 异步模式 8 位发送/ 接收 连续接收 低波特率
Open2USART( USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW,15 );
LATG &= ~0x18;//485 DE,/R/E
PORTG &= ~0x18;
TRISG &= ~0x18;
LATG |= 0x18;//DE Enable
// PORTG &= ~0x08;//DE Enable
// PORTG &= ~0x10;
while (1)
{
/* Reset the LEDs */
// PORTB = 0;
/* Delay so human eye can see change */
// puts2USART( str ); // print string
Write2USART( 0x55 ); //write value of PORTD
/* Light the LEDs */
// PORTB = 0x5A;
/* Delay so human eye can see change */
delay ();
}
} |