Bonsoir les amis ,
J'utilise un pic 24fj1024GB610 , et j'ai rencontrer un problème au niveau de la transmission des données ,
le problème est que je reçois des donnée erronés au niveau du terminal ,
par exemple si j'envoi 200 il faut que je reçois C8 , mais par contre je reçois 0E !!!!
voici la configuration que j'ai mis , et aussi un simple code pour envoyer les données
J'utilise l’oscillation interne du pic 8Mhz , et pour voir les données , j'utilise le terminal ""USB SERIAL TERMINAL fourni par micro-chip , j'ai activé l'option "" show bytes in Hex instead of ASCII"" sur le terminal ,
Code:void UART1_Initialize(void) { /** Set the UART1 module to the options selected in the user interface. Make sure to set LAT bit corresponding to TxPin as high before UART initialization */ // STSEL 1; IREN disabled; PDSEL 8N; UARTEN enabled; RTSMD disabled; USIDL disabled; WAKE disabled; ABAUD disabled; LPBACK disabled; BRGH enabled; URXINV disabled; UEN TX_RX; // Data Bits = 8; Parity = None; Stop Bits = 1; U1MODE = (0x8008 & ~(1<<15)); // disabling UARTEN bit // UTXISEL0 TX_ONE_CHAR; UTXINV disabled; URXEN disabled; OERR NO_ERROR_cleared; URXISEL RX_ONE_CHAR; UTXBRK COMPLETED; UTXEN disabled; ADDEN disabled; U1STA = 0x00; // BaudRate = 9600; Frequency = 4000000 Hz; U1BRG 103; U1BRG = 0x67; // ADMADDR 0; ADMMASK 0; U1ADMD = 0x00; U1MODEbits.UARTEN = 1; // enabling UART ON bit U1STAbits.UTXEN = 1; } bool UART1_IsTxReady(void) { return (U1STAbits.TRMT && U1STAbits.UTXEN ); } void UART1_Write(uint8_t txData) { while(U1STAbits.UTXBF == 1) { } U1TXREG = txData; // Write the data byte to the USART. } int main(void) { // initialize the device SYSTEM_Initialize(); UART1_Initialize(); //UART1_Enable(); uint8_t a; a=200; while (1) { if(UART1_IsTxReady()==1) { UART1_Write(a); } } return 1; }
-----