• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   3 Anonymous Users






Re: 新手發問--- MPLAB SIM
#5
新會員
新會員


查看用戶資訊
那在請教版主

那初始設定的部份類似以下的code嗎?
因為我嘗試過先initialUSART後,使用printf()還是沒有輸出.
一定要使用putsUSART這種函數.
//************************************************
//* Function: Initialize USART *
//* - Initialize the RS-232 communication *
//* - Disable Interrupr for TxD *
//* - Enable Interrupt fro Rxd *
//* - Format: 9600, N, 8, 1 *
//************************************************
void InitializeUSART(void)
{
Open1USART( USART_TX_INT_OFF // Set TXSTA Reg. =0b00100100
& USART_RX_INT_ON // Set RCSTA Reg. =0b10010000
& USART_ASYNCH_MODE
& USART_EIGHT_BIT
& USART_CONT_RX
& USART_BRGH_HIGH
,103); // Set SPBRG=103, Baud Rate = 9600

RCSTAbits.SPEN=1;
TRISCbits.TRISC7=1; // Set input for RXD
TRISCbits.TRISC6=0; // Set output for TXD
PIE1bits.TXIE=0;
PIR1bits.RCIF=0;
IPR1bits.RCIP=1; // Set Receive of USART are High priority
PIE1bits.RCIE=1; // Enable RxD Interrupt
}

發表於: 2008/6/13 16:56
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 新手發問--- MPLAB SIM
#4
版主
版主


查看用戶資訊
printf 應是一樣的,差異在 18F452 與 18F87J50 的 UART 的設計是不全然一樣,87J50 是 EUSART 的設計。所以初始的設定會有不同。

發表於: 2008/6/13 14:24
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 新手發問--- MPLAB SIM
#3
新會員
新會員


查看用戶資訊
多謝版主回覆,回覆很快阿...

加入InitialUSART及使用putsUSART後測試OK

為何我使用18F87J50不能如18F452這樣直接使用printf()?

發表於: 2008/6/13 11:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 新手發問--- MPLAB SIM
#2
版主
版主


查看用戶資訊
printf 基本上是送到 UART1 , 所以你還要對 UART1 作初始設定。其設定範例可以參考 W401 C18 教材裡的第五章。

發表於: 2008/6/13 10:10
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


新手發問--- MPLAB SIM
#1
新會員
新會員


查看用戶資訊
同樣一段source code

#include <stdio.h>

#pragma config WDT = OFF // for PIC18F452
#pragma config WDTEN = OFF // for PIC18F87J50

void main (void)
{
printf ("Hello World\n");

while (1);
}

使用MPLAB SIM 透過UART1去顯示此字串
在PIC18F452測試OK
在PIC18F87J50 compiler也都成功,但是UART1就是不會顯示

我有對應不同的device使用不同的*.lkr

發表於: 2008/6/13 9:44
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

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... ]

教育訓練中心

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