kenny_zhou
Junior Member level 2
fcy pll
hello everyone !please give me a hand!
this is a UART code,when PC sned character to dsPIC30F4013 it is ok,but when the dsPIC30F4013 couldn't send the character"0x41" to the PC,what should i do?Thanks a lot!
#include "p30f4013.h"
#define FCY 14745600
_FOSC(CSW_FSCM_OFF & XT_PLL8);//use a external crystal ,the instruction cycle =1/(FOSC*PLL/4)
_FWDT(WDT_OFF);
_FBORPOR(PBOR_OFF & MCLR_EN);//disable power off pretect,enable MCLR
_FGS(CODE_PROT_OFF);//disable code pretect
void ini232(void);
void __attribute__((__interrupt__)) _U1RXInterrupt(void); /*Declare 232 interrupt ISRs*/
unsigned char rxdata;
int main (void)
{
unsigned char i;
ini232(); /* Call function to initialize the 232 Interrupts */
for(i=32;i!=0;i--); //wait a moment,
while(1)
{
U1TXREG=0x41;
while(U1STAbits.UTXBF);
IFS0bits.U1TXIF=0;
}
}
void ini232(void)
{
TRISFbits.TRISF2 =1;
TRISFbits.TRISF3 =0;
U1BRG =95; //9600 baud rate
IPC2bits.U1RXIP=7;
IEC0bits.U1TXIE=0;
IEC0bits.U1RXIE=1;
U1MODE =0x8020;
U1STAbits.UTXEN =1;
}
void __attribute__((__interrupt__)) _U1RXInterrupt(void)
{
IFS0bits.U1RXIF = 0;
rxdata=(char)U1RXREG;
}
hello everyone !please give me a hand!
this is a UART code,when PC sned character to dsPIC30F4013 it is ok,but when the dsPIC30F4013 couldn't send the character"0x41" to the PC,what should i do?Thanks a lot!
#include "p30f4013.h"
#define FCY 14745600
_FOSC(CSW_FSCM_OFF & XT_PLL8);//use a external crystal ,the instruction cycle =1/(FOSC*PLL/4)
_FWDT(WDT_OFF);
_FBORPOR(PBOR_OFF & MCLR_EN);//disable power off pretect,enable MCLR
_FGS(CODE_PROT_OFF);//disable code pretect
void ini232(void);
void __attribute__((__interrupt__)) _U1RXInterrupt(void); /*Declare 232 interrupt ISRs*/
unsigned char rxdata;
int main (void)
{
unsigned char i;
ini232(); /* Call function to initialize the 232 Interrupts */
for(i=32;i!=0;i--); //wait a moment,
while(1)
{
U1TXREG=0x41;
while(U1STAbits.UTXBF);
IFS0bits.U1TXIF=0;
}
}
void ini232(void)
{
TRISFbits.TRISF2 =1;
TRISFbits.TRISF3 =0;
U1BRG =95; //9600 baud rate
IPC2bits.U1RXIP=7;
IEC0bits.U1TXIE=0;
IEC0bits.U1RXIE=1;
U1MODE =0x8020;
U1STAbits.UTXEN =1;
}
void __attribute__((__interrupt__)) _U1RXInterrupt(void)
{
IFS0bits.U1RXIF = 0;
rxdata=(char)U1RXREG;
}