Re: P18F4520 USART設定...請問版主
|
||||
---|---|---|---|---|
版主
|
我記得 Microchip 的 UART 函數會去判斷是否有使用9-bit 傳輸的。不過我還是建議你將相關的 UART Source cdoe 函數找出來加以檢查一下,畢竟使用 9-bit 的功能還是要看一下其操作的程序,9-bit 接收後 bit 9 又釋放在哪裡的這些都是要看一下 Source Code 才會了解的。
發表於: 2009/9/28 11:33
|
|||
|
Re: P18F4520 USART設定...請問版主
|
||||
---|---|---|---|---|
資深會員
|
請教版主,以下是C18內建的USART函式
因為在應用上有個疑問,我目前使用9BIT模式, TX9D放的是parity,會將TXSTAbits.TX9設為1, 但我使用這個內建函式時會有問題, 一進入函式內因為我的TX9=1,那我TX9D會立刻被設定為0, 還是這個函式不適用在9BIT模式,須要自己寫一個嗎? void WriteUSART(char data) { if(TXSTAbits.TX9) // 9-bit mode? { TXSTAbits.TX9D = 0; // Set the TX9D bit according to the if(USART_Status.TX_NINE) // USART Tx 9th bit in status reg TXSTAbits.TX9D = 1; } TXREG = data; // Write the data byte to the USART }
發表於: 2009/9/28 9:09
|
|||
|
Re: P18F4520 USART設定
|
||||
---|---|---|---|---|
資深會員
|
了解了,感謝版大回覆!
發表於: 2009/8/17 15:32
|
|||
|
Re: P18F4520 USART設定
|
||||
---|---|---|---|---|
版主
|
接收時還是要以相同的 9-bit Data Mode 接收,Parity 要不要算出來檢驗隨你高興,收近來後直接放棄parity 的檢查當然可以。
發表於: 2009/8/17 15:01
|
|||
|
Re: P18F4520 USART設定
|
||||
---|---|---|---|---|
資深會員
|
感謝版大的指點,另外請教版大,接收時應該就不需要特別這樣去判斷奇偶同位了吧?
發表於: 2009/8/17 14:54
|
|||
|
Re: P18F4520 USART設定
|
||||
---|---|---|---|---|
版主
|
可以做得到的。使用 9-bit Data Mode 即可,d0~D7 使用軟體方式計算出 Even Parity Bit 後將其填入 Tx9 的位元後傳送即可完成。
發表於: 2009/8/17 13:59
|
|||
|
P18F4520 USART設定
|
||||
---|---|---|---|---|
資深會員
|
各位大大,小弟目前用P18F4520來偵測鋰電池保護板資訊,
但保護保USART的通訊格試為4800 8 E 1,我看了P18F4520的DATASHEET好像無法設定為8 E 1只能設定8 N 1,不知是否真的這樣,各位大大是否可指點一下?
發表於: 2009/8/17 12:04
|
|||
|