• slider image 442
  • slider image 477
  • slider image 479
  • slider image 480
  • slider image 481
  • slider image 482
:::


Browsing this Thread:   1 Anonymous Users




(1) 2 »


Re: 有關於printf函數 for MPLAB X IDE v5.5
#13
管理員
管理員


查看用戶資訊
非常感謝您提供的資訊, 我測試時沒有使用PIC18 的這個系列因此無法複製出問題, 再次感謝!

發表於: 2021/11/29 7:47
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關於printf函數 for MPLAB X IDE v5.5
#12
初級會員
初級會員


查看用戶資訊
Hi Libra

感謝您的協助

我的問題已解決,提供給使用K40系列MCU的同學,在使用陣列寫入字串時,會有無法正常寫入的問題!
step1.在同一個專案裡,新增一個組合語言,檔名為powerup.as
step2.輸入以下code(以下摘錄自PIC18F27/47K40 Family Silicon Errata and Data Sheet Clarification)

#include
GLOBAL powerup, start
PSECT powerup, class=CODE, delta=1,
reloc=2
powerup:
BSF NVMCON1, 7
GOTO start
end

參考資訊:
https://www.microchip.com/forums/m957860.aspx

發表於: 2021/11/27 21:02
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關於printf函數 for MPLAB X IDE v5.5
#11
管理員
管理員


查看用戶資訊
已有使用E-Mail回復您了喔, 我這邊測試是正常的, 使用printf發送"xxxx"字串時, 所有的字元都有送到UART TX暫存器中發送, 可能要再查看看是哪邊的問題.

發表於: 2021/11/23 8:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關於printf函數 for MPLAB X IDE v5.5
#10
初級會員
初級會員


查看用戶資訊
Libra 您好
已寄出請查收
謝謝協助

發表於: 2021/11/18 13:28
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關於printf函數 for MPLAB X IDE v5.5
#9
管理員
管理員


查看用戶資訊
三種方式都沒有輸出嗎? 方便將專案寄給我看看嗎?
libra.chien@microchip.com

發表於: 2021/11/18 8:19
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關於printf函數 for MPLAB X IDE v5.5
#8
初級會員
初級會員


查看用戶資訊
Libra 您好
經過測試後,仍然沒有輸出
會不會是MPLAB X IDE版本的問題
或是在寫入字串矩陣的語法有改變呢?

發表於: 2021/11/17 18:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關於printf函數 for MPLAB X IDE v5.5
#7
管理員
管理員


查看用戶資訊
Heap 是動態記憶體的預留空間, XC8底下沒有Heap的設定,

理論上直接將字串送給printf不會有問題,
但是將字串矩陣指標傳進去就可能會因為記憶體指標錯誤而出錯
如:(可能會出錯的寫法)
void PrintStrcharString )
{
   
printf("%s"String );
}
void main()
{
    
PrintStr((char*)"Tx Success!\n");
}


如果改成下面這樣寫是否可以正常呢?

char Input_Buffer[20] = "Tx Success!\n";
printf("%s"Input_Buffer);

或是

#include <string.h>
char Input_Buffer[20];
strcpyInput_Buffer"Tx Success!\n" );
printfInput_Buffer );


或是

#include <string.h>
char Input_Buffer[20];
sprintfInput_Buffer"%s""Tx Success!\n" );
printfInput_Buffer );

發表於: 2021/11/16 9:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關於printf函數 for MPLAB X IDE v5.5
#6
初級會員
初級會員


查看用戶資訊
參照:

Ryang wrote:
接收速度可以跟的上傳送的速度嗎?
用示波器量一下,確定是否有輸出?
完整的字串最後還有一個 NULL Byte (0x00)。


Ryang 您好

1.接收與上傳的速度均設定為19200bps
2.直接使用printf("Tx Success!\n")這種程式寫法,示波器也測不到波形
除非以下這樣寫法
Input_Buffer[0]='T'
Input_Buffer[1]='x'
Input_Buffer[2]=' '
Input_Buffer[3]='S'
Input_Buffer[4]='u'
Input_Buffer[5]='c'
Input_Buffer[6]='c'
Input_Buffer[7]='e'
Input_Buffer[8]='s'
Input_Buffer[9]='s'
Input_Buffer[10]='!'
然後printf(Input_Buffer)就可量測到波形,且可正確的傳到UART
3.在字串後面加 NULL Byte也一樣無輸出printf("Tx Success!\n")

發表於: 2021/11/15 22:16
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關於printf函數 for MPLAB X IDE v5.5
#5
初級會員
初級會員


查看用戶資訊
Libra 您好
我用的是PIC18F47K40
SRAM大小為3728 Bytes
使用XC8(V2.32)

另外Heap什麼呢?如何調整呢?是否有相關的資料可以參考呢?
謝謝

發表於: 2021/11/15 13:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關於printf函數 for MPLAB X IDE v5.5
#4
管理員
管理員


查看用戶資訊
請問MCU的型號(SRAM大小)? 使用 XC8 / XC16 / XC32 ?
printf 使用較大的heap來進行字串的傳送, 部分8-bit MCU因為SRAM不足, 無法實現完整的 stdio 功能.
可以嘗試將Heap放大試試

發表於: 2021/11/15 10:08
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... ]

教育訓練中心

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