C
Chandra
Guest
Ja sam koristeći 24hj128gp306 i žele uspostaviti vezu sa PC terminal program at 115200bps.PIC24HJ Ja sam koristeći UART2.
Ali ja sam ne uzimajući bilo znakova na pc.Anybody mogu provjeriti i kod mene pomoć.
# include <p24Hxxxx.h>
# include <libpic30.h>
# include <uart.h>
# define FCY 7372800 / / FCY = FOSC / 2
# define BAUDRATE 115.200
# define BRGVAL ((FCY / BAUDRATE) / 16) -1
/ / / Macros Configuration
_FOSCSEL (FNOSC_PRI);
_FOSC (FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_HS);
_FWDT (FWDTEN_OFF);
_FPOR (FPWRT_PWR1);
_FGS (GCP_OFF);int main ()
(
unsigned int i;
char Txdata [] = ( 'M', 'i', 'c', 'r', 'o', 'c', 'h', 'i', 'p', '', 'ja', ' C ',' D ', '2', '\ 0'); / / / znakovi da emitira
_ODCF5 = 0; / / openr Drain Configuration
_TRISF5 = 0; / / Tx igla je izlazni pin
_LATF5 = 1; / / izlaz Latch
U1MODEbits.STSEL = 0; / / 1-stop bita
U1MODEbits.PDSEL = 0; / / Ne Paritet, 8-bita podataka
U1MODEbits.ABAUD = 0; / / Autobaud Disabled
U1BRG = BRGVAL; / / generator takta za prijenos podataka Prescalar Pogledajte Tablica 3-10 9600
U1STAbits.UTXISEL0 = 0;
U1STAbits.UTXISEL1 = 0;
IEC0bits.U1TXIE = 0;
U1MODEbits.UARTEN = 1; / / Enable UART
U1STAbits.UTXEN = 1; / / Enable UART Tx
/ / for (i = 0; 1 <4.160; i );
putsUART1 ((unsigned int *) Txdata);
/ / while (1) ()
return 0;
)
Ali ja sam ne uzimajući bilo znakova na pc.Anybody mogu provjeriti i kod mene pomoć.
# include <p24Hxxxx.h>
# include <libpic30.h>
# include <uart.h>
# define FCY 7372800 / / FCY = FOSC / 2
# define BAUDRATE 115.200
# define BRGVAL ((FCY / BAUDRATE) / 16) -1
/ / / Macros Configuration
_FOSCSEL (FNOSC_PRI);
_FOSC (FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_HS);
_FWDT (FWDTEN_OFF);
_FPOR (FPWRT_PWR1);
_FGS (GCP_OFF);int main ()
(
unsigned int i;
char Txdata [] = ( 'M', 'i', 'c', 'r', 'o', 'c', 'h', 'i', 'p', '', 'ja', ' C ',' D ', '2', '\ 0'); / / / znakovi da emitira
_ODCF5 = 0; / / openr Drain Configuration
_TRISF5 = 0; / / Tx igla je izlazni pin
_LATF5 = 1; / / izlaz Latch
U1MODEbits.STSEL = 0; / / 1-stop bita
U1MODEbits.PDSEL = 0; / / Ne Paritet, 8-bita podataka
U1MODEbits.ABAUD = 0; / / Autobaud Disabled
U1BRG = BRGVAL; / / generator takta za prijenos podataka Prescalar Pogledajte Tablica 3-10 9600
U1STAbits.UTXISEL0 = 0;
U1STAbits.UTXISEL1 = 0;
IEC0bits.U1TXIE = 0;
U1MODEbits.UARTEN = 1; / / Enable UART
U1STAbits.UTXEN = 1; / / Enable UART Tx
/ / for (i = 0; 1 <4.160; i );
putsUART1 ((unsigned int *) Txdata);
/ / while (1) ()
return 0;
)