• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::

論壇索引


Board index » All Posts (tedc)




app026-3 UART 115200 baud rate
#1
新會員
新會員


我測試 9600 ok 可是115200不行,請問有什麼要注意的嗎?
// JTAG/Code Protect/Write Protect/Clip-on Emulation mode
// Watchdog Timer/ICD pins select
_CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
// Disable CLK switch and CLK monitor, OSCO or Fosc/2, HS oscillator,
// Primary oscillator
_CONFIG2(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)

UARTInit()
{
TRISFbits.TRISF3 = 0;

// This is an EXAMPLE, so brutal typing goes into explaining all bit sets

//********************************************************************************
// STEP 1: configure U1MODE
// No Flow Control Mode, No Loop-Back
// No Auto-Baud, No Rx-Inversion
// Low BaudRate,
// 8-bit with no parity
// 1 Stop-bit
// bit 14, bit 10 no use
//********************************************************************************/

U1MODEbits.UARTEN = 0; // Bit15 TX, RX DISABLED, ENABLE at end of func
//= 0; // Bit14 no use
U1MODEbits.USIDL = 0; // Bit13 Continue in Idle
U1MODEbits.IREN = 0; // Bit12 No IR translation

U1MODEbits.RTSMD = 0; // Bit11 Simplex Mode
//= 0; // Bit10 no use
U1MODEbits.UEN = 0; // Bits8,9 TX,RX enabled, CTS,RTS not

U1MODEbits.WAKE = 0; // Bit7 No Wake up (since we don't sleep here)
U1MODEbits.LPBACK = 0; // Bit6 No Loop Back
U1MODEbits.ABAUD = 0; // Bit5 No Autobaud (would require sending '55')
U1MODEbits.RXINV = 0; // Bit4 IdleState = 1

U1MODEbits.BRGH = 0; // Bit3 16 clocks per bit period
U1MODEbits.PDSEL = 0; // Bits1,2 8bit, No Parity
U1MODEbits.STSEL = 0; // Bit0 One Stop Bit

//********************************************************************************
// STEP 2:
// Load the count to get 300 baudrate
// BRG = Fcy/(16*BaudRate)-1 where Fcy = Fosc/2 = 4MHz
//********************************************************************************/
U1BRG = 0x01; //0x19;

//********************************************************************************
// STEP 3:
// Tx Interrupt to interrupt when at least one location is free in Tx buffer
// No Tx Inversion, Disable Sync Break
// Enable Transmit, Disable Address Detect
// Interrupt on every receive.
// bit 12 no use
//********************************************************************************/

U1STAbits.UTXISEL1 = 0; //Bit15 Int when Char is transferred (1/2 config!)
U1STAbits.UTXINV = 0; //Bit14 N/A, IRDA config
U1STAbits.UTXISEL0 = 0; //Bit13 Other half of Bit15
//= 0; //bit 12 no use

U1STAbits.UTXBRK = 0; //Bit11 Disabled
U1STAbits.UTXEN = 0; //Bit10 TX pins controlled by UART1
U1STAbits.UTXBF = 0; //Bit9 *Read Only Bit*
U1STAbits.TRMT = 0; //Bit8 *Read Only bit*

U1STAbits.URXISEL = 0; //Bits6,7 Int. on character recieved
U1STAbits.ADDEN = 0; //Bit5 Address Detect Disabled
U1STAbits.RIDLE = 0; //Bit4 *Read Only Bit*

U1STAbits.PERR = 0; //Bit3 *Read Only Bit*
U1STAbits.FERR = 0; //Bit2 *Read Only Bit*
U1STAbits.OERR = 0; //Bit1 *Read Only Bit*
U1STAbits.URXDA = 0; //Bit0 *Read Only Bit*

IFS0bits.U1TXIF = 0; // Clear the Transmit Interrupt Flag
IEC0bits.U1TXIE = 0; // Enable Transmit Interrupts
IFS0bits.U1RXIF = 0; // Clear the Recieve Interrupt Flag
IEC0bits.U1RXIE = 1; // Enable Recieve Interrupts

U1MODEbits.UARTEN = 1; // And turn the peripheral on
U1STAbits.UTXEN = 1;
}

發表於: 2009/7/7 16:30
頂部


app026-3 UART 115200 baud rate
#2
新會員
新會員


我測試 9600 ok 可是115200不行,請問有什麼要注意的嗎?
// JTAG/Code Protect/Write Protect/Clip-on Emulation mode
// Watchdog Timer/ICD pins select
_CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
// Disable CLK switch and CLK monitor, OSCO or Fosc/2, HS oscillator,
// Primary oscillator
_CONFIG2(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)

UARTInit()
{
TRISFbits.TRISF3 = 0;

// This is an EXAMPLE, so brutal typing goes into explaining all bit sets

//********************************************************************************
// STEP 1: configure U1MODE
// No Flow Control Mode, No Loop-Back
// No Auto-Baud, No Rx-Inversion
// Low BaudRate,
// 8-bit with no parity
// 1 Stop-bit
// bit 14, bit 10 no use
//********************************************************************************/

U1MODEbits.UARTEN = 0; // Bit15 TX, RX DISABLED, ENABLE at end of func
//= 0; // Bit14 no use
U1MODEbits.USIDL = 0; // Bit13 Continue in Idle
U1MODEbits.IREN = 0; // Bit12 No IR translation

U1MODEbits.RTSMD = 0; // Bit11 Simplex Mode
//= 0; // Bit10 no use
U1MODEbits.UEN = 0; // Bits8,9 TX,RX enabled, CTS,RTS not

U1MODEbits.WAKE = 0; // Bit7 No Wake up (since we don't sleep here)
U1MODEbits.LPBACK = 0; // Bit6 No Loop Back
U1MODEbits.ABAUD = 0; // Bit5 No Autobaud (would require sending '55')
U1MODEbits.RXINV = 0; // Bit4 IdleState = 1

U1MODEbits.BRGH = 0; // Bit3 16 clocks per bit period
U1MODEbits.PDSEL = 0; // Bits1,2 8bit, No Parity
U1MODEbits.STSEL = 0; // Bit0 One Stop Bit

//********************************************************************************
// STEP 2:
// Load the count to get 300 baudrate
// BRG = Fcy/(16*BaudRate)-1 where Fcy = Fosc/2 = 4MHz
//********************************************************************************/
U1BRG = 0x01; //0x19;

//********************************************************************************
// STEP 3:
// Tx Interrupt to interrupt when at least one location is free in Tx buffer
// No Tx Inversion, Disable Sync Break
// Enable Transmit, Disable Address Detect
// Interrupt on every receive.
// bit 12 no use
//********************************************************************************/

U1STAbits.UTXISEL1 = 0; //Bit15 Int when Char is transferred (1/2 config!)
U1STAbits.UTXINV = 0; //Bit14 N/A, IRDA config
U1STAbits.UTXISEL0 = 0; //Bit13 Other half of Bit15
//= 0; //bit 12 no use

U1STAbits.UTXBRK = 0; //Bit11 Disabled
U1STAbits.UTXEN = 0; //Bit10 TX pins controlled by UART1
U1STAbits.UTXBF = 0; //Bit9 *Read Only Bit*
U1STAbits.TRMT = 0; //Bit8 *Read Only bit*

U1STAbits.URXISEL = 0; //Bits6,7 Int. on character recieved
U1STAbits.ADDEN = 0; //Bit5 Address Detect Disabled
U1STAbits.RIDLE = 0; //Bit4 *Read Only Bit*

U1STAbits.PERR = 0; //Bit3 *Read Only Bit*
U1STAbits.FERR = 0; //Bit2 *Read Only Bit*
U1STAbits.OERR = 0; //Bit1 *Read Only Bit*
U1STAbits.URXDA = 0; //Bit0 *Read Only Bit*

IFS0bits.U1TXIF = 0; // Clear the Transmit Interrupt Flag
IEC0bits.U1TXIE = 0; // Enable Transmit Interrupts
IFS0bits.U1RXIF = 0; // Clear the Recieve Interrupt Flag
IEC0bits.U1RXIE = 1; // Enable Recieve Interrupts

U1MODEbits.UARTEN = 1; // And turn the peripheral on
U1STAbits.UTXEN = 1;
}

發表於: 2009/7/7 16:28
頂部


Re: 請問APP026-3 ver4 的 uart 有沒有 example
#3
新會員
新會員


sorry , 我要的是 pic24 的範例程式, Thanks

發表於: 2008/3/19 12:36
頂部


請問APP026-3 ver4 的 uart 有沒有 example
#4
新會員
新會員


好像沒有app026-3 ver4 的說明,請問有沒有 uart 的 example
Thanks

發表於: 2008/3/18 21:48
頂部


想用USB PIC 來教學是否有資料可以提供
#5
新會員
新會員


想用USB PIC 來教單晶片:
不知是否有利用 usb作ISP的功能。
或是有其他資料可以參考。
Thanks

發表於: 2005/4/1 21:51
頂部


Re: PICDEM Z 2.4 GHz 台灣有賣嗎
#6
新會員
新會員


禾伸堂可以幫忙訂購.
(02)26596720-206蕭先生
不過要訂金而且4-6 week 才能拿到

發表於: 2005/1/7 16:18
頂部


PIC18F2455 有sample可以索取嗎
#7
新會員
新會員


我想測試一下 usb function,不知是否有sample可以索取嗎??
Thanks for your help

發表於: 2005/1/4 17:51
頂部


PICDEM Z 2.4 GHz 台灣有賣嗎
#8
新會員
新會員


Dear Sir :
I want to buy PICDEM Z 2.4 GHz Demonstration Kit, can you give me some information.
Ted Chen

發表於: 2005/1/4 14:18
頂部






:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------