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

論壇索引


Board index » All Posts




mplab x ide new watch 看陣列位置順序問題
中級會員
中級會員


我沒有去改變顯示順序,[7], 6] ,[5], [4] ,希望能從 [0],[1],[2]~~~ [n] , 如何修改
附上檔案如附件

Attach file:



jpg  圖片 1.jpg (84.38 KB)
110549_610233cce411e.jpg 1539X118 px

發表於: 2021/7/29 12:51
頂部


PIC16F1823 中斷應用
新會員
新會員


各位好,我剛入門C也是第一次用PIC16F1823,開發環境為 MPLAB X IDE 5.50+XC8 2.31+MCC 4.2.3

我有一個功能是藉由ADC轉換後再針對其值判斷而做不同的行為,但我需要每1us就去偵測判斷
所以我想到了使用中斷執行。如果我用timr0去做1us的時間中斷,再去讀取ADC(使用MCC產生的ADC_GetConversion函式)
但是我在主程式中也有用到ADC_GetConversion這個函式,假如我進入中斷前剛好在執行這個ADC_GetConversion函式,會不會影響我中斷執行時的轉換?是否需要在另外寫一個給中斷使用?

另外,因為我怕中斷程式時間太長導致又觸發中斷,所以我想在中斷產生一個旗標,然後在結束中斷後直接跳去該旗標的地方執行其他程式,請問該怎麼去寫這段?
還是我只要將ISR中INTCONbits.TMR0IF = 0;移到中斷程式的最後一步就可以等全部都做完後再開始重新計數timer0?

如下為兩個用到的函式
-----------------------------------------------------------------------------------------------------------
MCC ADC 函式:
adc_result_t ADC_GetConversion(adc_channel_t channel)
{
// select the A/D channel
ADCON0bits.CHS = channel;

// Turn on the ADC module
ADCON0bits.ADON = 1;

// Acquisition time delay
__delay_us(ACQ_US_DELAY);

// Start the conversion
ADCON0bits.GO_nDONE = 1;

// Wait for the conversion to finish
while (ADCON0bits.GO_nDONE)
{
}

// Conversion finished, return the result
return ((adc_result_t)((ADRESH << 8) + ADRESL));
}
-----------------------------------------------------------------------------------------------------------
timer0 isr
void TMR0_ISR(void)
{
uint16_t ADC_OVP;
// Clear the TMR0 interrupt flag
INTCONbits.TMR0IF = 0;

TMR0 = timer0ReloadVal;

if(TMR0_InterruptHandler)
{
TMR0_InterruptHandler();
}

// add your TMR0 interrupt custom code
ADC_OVP = ADC_GetConversion(channel_AN5);
.............
.............
.............
}

發表於: 2021/7/29 11:51
頂部


PIC18 XC8編譯問題
新會員
新會員


目前開啟一個已完成的專案,進行編譯時出現錯誤如下(擷取一部分)
make[2]: *** [build/default/production/mcc_generated_files/pin_manager.p1] Error 1
make[2]: *** [build/default/production/mcc_generated_files/uart1.p1] Error 1
nbproject/Makefile-default.mk:203: recipe for target 'build/default/production/mcc_generated_files/pin_manager.p1' failed
(908) exit status = 1
nbproject/Makefile-default.mk:211: recipe for target 'build/default/production/mcc_generated_files/uart1.p1' failed
::: error: (2047) 24-bit floating point types are not supported when compiling in C99
(908) exit status = 1
nbproject/Makefile-default.mk:227: recipe for target 'build/default/production/mcc_generated_files/pwm5.p1' failed
make[2]: *** [build/default/production/mcc_generated_files/pwm5.p1] Error 1
::: error: (2047) 24-bit floating point types are not supported when compiling in C99
(908) exit status = 1
make[2]: *** [build/default/production/mcc_generated_files/uart2.p1] Error 1
nbproject/Makefile-default.mk:219: recipe for target 'build/default/production/mcc_generated_files/uart2.p1' failed
::: error: (2047) 24-bit floating point types are not supported when compiling in C99
make[2]: *** [build/default/production/mcc_generated_files/tmr2.p1] Error 1


因為專案是完成的,所以在找原因,用了不同電腦開啟,編譯結果不同,
相同專案,不同電腦都使用MPLABX開啟,一個編譯OK,一個編譯錯誤,
OK電腦的PACK和XC8版本:
PIC18F-DFP = 1.3.84
XC8 = V1.45

編譯錯誤的PACK和XC8版本:
PIC18F-DFP = 1.4.87
XC8 = V2.32
但若是建立一個新的相同MCU的專案,則編譯OK

1. 請問編譯錯誤是編譯器的問題嗎?
2. 為何新版編譯器無法向下相容?需要什麼設定嗎?

Attach file:



gif  PIC18F編譯錯誤.GIF (30.20 KB)
74357_6100e56041585.gif 1379X659 px

發表於: 2021/7/28 13:09
頂部


Re: MCC4.2.1 設定 RE2 為輸入...但GEN CODE出來被設為輸出?
版主
版主


因為看不到你在 MCC 裡所設定的腳位狀態。請參考一下貼圖後檢查一下你的腳位設定,尤其是 GPIO 所設定的是 Input 或Output 的功能。

Attach file:



jpg  擷取.JPG (38.21 KB)
16_6100baae03413.jpg 574X190 px

發表於: 2021/7/28 9:47
頂部


Re: MCC4.2.1 設定 RE2 為輸入...但GEN CODE出來被設為輸出?
高級會員
高級會員


這隻腳的基本功能是 COM7/SEG34/RE2,是不是有使用到 LCD 的功能?或者,你有使用 PPS 在規劃接腳時有用到這隻腳。

MCC 我沒有使用LCD的模組...RE2就單獨設為輸入而已...
PPS

INTPPS = 0x08; //RB0->EXT_INT:INT;
SSP1CLKPPS = 0x13; //RC3->MSSP1:SCK1;
RC3PPS = 0x13; //RC3->MSSP1:SCK1;
RC2PPS = 0x0A; //RC2->CCP2:CCP2;
RC6PPS = 0x0D; //RC6->EUSART1:TX1;
SSP1DATPPS = 0x14; //RC4->MSSP1:SDI1;

應該也沒有用到RE2...




發表於: 2021/7/27 16:44
頂部


Re: MCC4.2.1 設定 RE2 為輸入...但GEN CODE出來被設為輸出?
版主
版主


這隻腳的基本功能是 COM7/SEG34/RE2,是不是有使用到 LCD 的功能?
或者,你有使用 PPS 在規劃接腳時有用到這隻腳。

發表於: 2021/7/27 13:32
頂部


MCC4.2.1 設定 RE2 為輸入...但GEN CODE出來被設為輸出?
高級會員
高級會員


PIC16F19185 ... 我在XIDE 5.45 中,MCC4.2.1 , 設置RE2為輸入時,轉出來的初始化...卻要把RE2設為輸出??是這隻IO有其它要注意的地方嗎???

Attach file:



jpg  擷取.JPG (108.51 KB)
16_6100b840bbf95.jpg 944X537 px

發表於: 2021/7/27 9:58

Edited by Ryang on 2021年07月28日 09:48:57
Edited by Ryang on 2021年07月28日 09:49:21
Edited by Ryang on 2021年07月28日 09:51:11
Edited by Ryang on 2021年07月28日 09:51:32
Edited by Ryang on 2021年07月28日 09:52:00
頂部


Re: SAM C21 Xplained Pro 開發版
管理員
管理員



發表於: 2021/7/26 14:26
頂部


SAM C21 Xplained Pro 開發版
中級會員
中級會員


hi Liba
我使用SAM C21 Xplained Pro 開發版,我把來從,usb connector 提供板子電源,發現輸出電壓5v 只剩下 4.389v,我改從板子vin
外掛獨立電源 5v堤供給他,但usb connector 必須移除,才不會有兩邊供電情形,但我無法除厝與燒錄,要如何處理

Attach file:



jpg  5v.jpg (240.67 KB)
110549_60fe4bc8f27f6.jpg 895X549 px

發表於: 2021/7/26 13:44
頂部


Re: atsamc21 相關sample code
中級會員
中級會員


hi Liba
感謝,已經ok

發表於: 2021/7/26 13:18
頂部



« 1 ... 136 137 138 (139) 140 141 142 ... 7523 »



:::

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

教育訓練中心

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