Re: 關於Halting build on first failure as requested.
|
||||
---|---|---|---|---|
中級會員
|
你好!
你目前問題的主要原因是因為你所使用的 c30 版本太舊, 無法支援到你的 pic24F 元件所致. 請先下載新版的 c30 再試試吧!
發表於: 2009/1/9 8:50
|
|||
|
Re: 請教 30F2020的SPI問題
|
||||
---|---|---|---|---|
中級會員
|
在以下這裡會造成問題.
/*設置SPI中斷*/ IFS0bits.SPI1IF = 0 ; //未產生中斷 IEC0bits.SPI1IE = 1 ; //允許中斷 IPC2bits.SPI1IP = 4 ; //中斷優先權 = 4 ----------------------------------------------- 因為在你的程式中很明顯的並未使用 spi 中斷程序, 所以如果你開啟了中斷致能會使得 MCU 進入 SPI 中斷裡面, 導致錯誤發生, 應該改為不致能進入 SPI 中斷程序. /*設置SPI中斷*/ IFS0bits.SPI1IF = 0 ; //未產生中斷 IEC0bits.SPI1IE = 0 ; //不致能進入中斷處理程序 IPC2bits.SPI1IP = 4 ; //中斷優先權 = 4
發表於: 2008/12/26 7:04
|
|||
|
Re: 請教 30F2020的SPI問題
|
||||
---|---|---|---|---|
中級會員
|
你好! 還有問題的話請你試試如下:
------------------------------------------------------------------------------------- int spi_char; cs = low; _SPI1IF = 0; SPI1BUF = 0X02 ; //先傳指令 while(_SPI1IF == 0); _SPI1IF = 0; // 清除 SPI 中斷旗號 spi_char = SPI1BUF; SPI1BUF = 0X01 ; //再傳address while(_SPI1IF == 0); _SPI1IF = 0; // 清除 SPI 中斷旗號 spi_char = SPI1BUF; SPI1BUF = 0X33 ; //最後是data while(_SPI1IF == 0); // _SPI1IF = 0; // 清除 SPI 中斷旗號 spi_char = SPI1BUF; cs = hi; ------------------------------------------------------------------------------------- 加上這個讀取動作, 這是因為 dspic30F 的 spi 是一個雙向動作的模組, 如果沒有讀出的動作時, 會有讀入資料溢位的錯誤產生, 或許是讀入資料的溢位錯誤導致新的資料輸出無動作吧!
發表於: 2008/12/25 22:21
|
|||
|
Re: 請教 30F2020的SPI問題
|
||||
---|---|---|---|---|
中級會員
|
你好! 你現在的程式中有個不太對的地方,
if (!SPI1STATbits.SPITBF); //再次確定已傳送出去 在這裡應該使用 while(SPI1STATbits.SPITBF); 因為 SPI 的傳送動作是需要時間的, 以你的原方式則不會等待到 SPI 資料傳遞到 SPIxSR. ------------------------------------------------------------------------------------- cs = low; SPI1BUF = 0X02 ; //先傳指令 while(SPI1STATbits.SPITBF); // 若 SPITBF == 1表示未傳出, 需等待 SPI1BUF = 0X01 ; //再傳address while(SPI1STATbits.SPITBF); // 若 SPITBF == 1表示未傳出, 需等待 SPI1BUF = 0X33 ; //最後是data while(SPI1STATbits.SPITBF); // 若 SPITBF == 1表示未傳出, 需等待 cs = hi; ------------------------------------------------------------------------------------- 另外, 當 SPI 以 master 模式使用時, 在 SPI 傳送結束時會產生中斷旗號 (_SPI1IF = 1) 可以判斷 _SPI1IF 來知道 SPI 傳送是否要結束了, 或是要接著傳下一個資料出去. cs = low; _SPI1IF = 0; SPI1BUF = 0X02 ; //先傳指令 while(_SPI1IF == 0); _SPI1IF = 0; // 清除 SPI 中斷旗號 SPI1BUF = 0X01 ; //再傳address while(_SPI1IF == 0); // SPI1BUF = 0X33 ; //最後是data while(_SPI1IF == 0); // _SPI1IF = 0; // 清除 SPI 中斷旗號 cs = hi; ------------------------------------------------------------------------------------- GOOD LUCK !!!!!
發表於: 2008/12/25 11:10
|
|||
|
Re: i/o模擬uart 傳接收
|
||||
---|---|---|---|---|
中級會員
|
你好!
突然發現你的程式很明顯少了 start bit 的部分. 建議你加上 start bit 在實際的傳送資料前面, 再試一下吧!
#include <p18f4620.h>
發表於: 2008/11/25 23:34
|
|||
|
Re: UART問題
|
||||
---|---|---|---|---|
中級會員
|
你好!
你所提的是像 dsPIC30F4011 這種其中有 UART_ALTRX_ALTTX 的, 這是用來選擇 UART1 的 TX RX I/O 腳位置的, dsPIC30F4011 的 TX RX 是有兩處配置可供選擇來使用的, 除了 RF3/U1TX, RF2/U1RX 的 I/O 位置外, 另外還有 RC13/U1ATX, RC14/U1ARX 的 I/O 位置, 當設定 UART1 為 UART_ALTRX_ALTTX 表示使用 U1ATX/U1ARX 的 I/O 位置, 如果設定 UART1 為 UART_RX_TX 則使用 U1TX/U1RX 的 I/O 位置, 但是請注意要使用 ICD2 這類工具時, U1TX/U1RX 會與 PGD/PGC 的 I/O 位置相同喔! 這個時候應該使用 U1ATX/U1ARX 的 I/O 位置, 以便利 DEBUG 的工作能順利運作.
發表於: 2008/10/15 9:15
|
|||
|
Re: 求助,关于初始化总是复位的错误,附原程序,谢谢
|
||||
---|---|---|---|---|
中級會員
|
你好!
沒有在你貼上的程序中看到 U2TX 與 U2RX 中斷程序, 所以很可能是你在 UART2_init() 中致能中斷所造成的, (可能 U2TX = 1 後即進入 U2TX 中斷了...) 請修改 IFS1bits.U2TXIF = 0; // Clear the Transmit Interrupt Flag IEC1bits.U2TXIE = 1; // Enable Transmit Interrupts IFS1bits.U2RXIF = 0; // Clear the Recieve Interrupt Flag IEC1bits.U2RXIE = 1; // Enable Recieve Interrupts 為 IFS1bits.U2TXIF = 0; // Clear the Transmit Interrupt Flag IEC1bits.U2TXIE = 0; // Disable Transmit Interrupts IFS1bits.U2RXIF = 0; // Clear the Recieve Interrupt Flag IEC1bits.U2RXIE = 0; // Disable Recieve Interrupts 然後看你需要做中斷處理時再設定 U2TXIE 與 U2RXIE Good Luck !!!!!
發表於: 2008/10/13 13:47
|
|||
|
Re: C18 // 註解用於 socket 上的問題
|
||||
---|---|---|---|---|
中級會員
|
你好!
如果是希望字串內容為 at^siss=1,address,"socktcp://123.205.192.117:3000" 這樣的話. 請試試敘述成 const rom far unsigned char RomMsg15[] = "at^siss=1,address,\"socktcp://123.205.192.117:3000\""; 反斜線同樣可將下一個相連的雙引號當作為字串的內容喔!
發表於: 2008/9/6 9:34
|
|||
|
Re: 請問幾個關於 PIC24FJ256GA108 的問題
|
||||
---|---|---|---|---|
中級會員
|
當要使用更大量的 const 資料時, 宣告 const 資料時請指定放入 program 的區域中,
如下所示, 可以不受 PSV 範圍的限制. *** 但是讀取資料亦不受 PSV 讀取協助, 請使用 tblrdl 方式來讀取 *** 又或者你的 RAM 有足夠空間時, *** 先行以 _memcpy_p2d16(void *dest, _prog_addressT src, unsigned int len) 複製到 RAM 宣告 const 放入 program 區域中 const unsigned int __attribute__((space(prog))) const_1[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_2[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_3[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_4[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_5[1000] = {1,2,3,4,5}; ---------------------------------------------------------------------------------- 使用 _memcpy_p2d16(void *dest, _prog_addressT src, unsigned int len) 複製到 RAM #include "p24fj128ga108.h" #include "libpic30.h" const unsigned int __attribute__((space(prog))) const_1[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_2[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_3[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_4[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_5[1000] = {1,2,3,4,5}; _prog_addressT const_ptr; unsigned int __attribute__((__far__)) const_temp[4096]; int main(void) { _init_prog_address(const_ptr, const_1); // 取得 const_1 的存放位址於 const_ptr _memcpy_p2d16(const_temp, const_ptr, sizeof(const_1)); // 將 const_1 的內容複製到 RAM 中 return 0; } ----------------------------------------------------------------------------------- 使用 tblrdl 的方式來讀取 const 資料內容 #include "p24fj128ga108.h" #include "libpic30.h" #define mem_const_int(const_value,const_p) \ { TBLPAG = const_p >> 16; \ WREG1 = const_p & 0xFFFF; \ asm("TBLRDL.W [W1],W2"); \ const_value = WREG2; \ const_p += 2; } #define mem_const_char(const_value,const_p) \ { TBLPAG = const_p >> 16; \ WREG1 = const_p & 0xFFFF; \ asm("TBLRDL.B [W1],W2"); \ const_value = WREG2 & 0xFF; \ const_p ++; } const unsigned int __attribute__((space(prog))) const_1[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_2[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_3[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_4[1000] = {1,2,3,4,5}; const unsigned int __attribute__((space(prog))) const_5[1000] = {1,2,3,4,5}; _prog_addressT const_index; unsigned int const_get; int main(void) { // 先取得 const_1 的位址放在 const_index 中, 以便接著順序取得 const 資料 _init_prog_address(const_index, const_1); // 呼叫 mem_const_int(const_get, const_index), 會依序取得 const_1 的資料內容 [0], [1], [2].... mem_const_int(const_get, const_index); mem_const_int(const_get, const_index); mem_const_int(const_get, const_index); mem_const_int(const_get, const_index); return 0; }
發表於: 2008/7/26 15:49
|
|||
|