• 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 (furbylin)




PIC 18F8720 PWM2無波形輸出
#1
新會員
新會員


請問:
OpenPWM1(0x10);
SetDCPWM1(dutycycle1);
在RC2有波形輸出.

OpenPWM2(0x10);
SetDCPWM2(dutycycle2);
為何在RC1沒有波形輸出?
Configure-> CCP2 Mux設為RC1
有什麼該設定而沒設嗎?
ps:dutycycle1, dutycycle2為變數

另外, 若要同時使用多組PWM, 共用一組Timer(如Timer2), 這樣不會有問題嗎?

謝謝!

發表於: 2005/12/27 18:23
頂部


Re: 關於 PIC10F206 的 delay
#2
新會員
新會員


問題已經解決了, 原來是MPLAB IDE 7.1的bug, 更新到7.3之後就沒有Calibration memory寫入, 會出現錯誤訊息的問題.

發表於: 2005/12/23 15:58
頂部


PIC10F202 compile程式遇到問題
#3
新會員
新會員


初次寫組合, 不知哪邊出問題
原始程式如下:
list      p=10F202            ; list directive to define processor
#include <p10F202.inc>        ; processor specific variable definitions

'__CONFIG' directive is used to embed configuration word within .asm file.
The lables following the directive are located in the respective .inc file
__CONFIG   _MCLRE_OFF _CP_ON _WDT_OFF


定義變數在RAM的位址
CBLOCK    0x08
    int_counter
    counter
ENDC


TMR0_TIMEOUT    EQU    0x7D    
125 0x7D 加上延遲
INTERNAL_TMR0    EQU    25

GP0        EQU 0x00
GP1        EQU 0x01
GP2        EQU 0x02
GP3        EQU 0x03


;RESET vector used to load calibration for internal clock
;;;RESET_VECTOR    CODE    0x1FF

Internal RC calibration value is placed at location 0x1FF by Microchip
; as a movlw kwhere the k is a literal value.

ORG 0x000
    movwf   OSCCAL            
update register with factory cal value 
    bsf     OSCCAL
,0

;***********************************************
;*         
Initial Timer0 subroutine
;***********************************************
Initial_Timer0
    clrf    TMR0
    movlw    
b'10000101'
    
OPTION                Prescaler 1:64
    retlw    0
;---------------------------------------------------------------------------

start                          the code start here
;initialisation GPIO inter osc 
    
    movlw    
b'00001000'    
    
tris     GPIO              

    movlw    INTERNAL_TMR0
    movwf    int_counter
    movlw    .16
    movwf    counter

    call     Initial_Timer0
    bsf        GPIO
GP0        High

loop1
    
;if (TMR0 >= TMR0_TIMEOUT)
    
movlw     TMR0_TIMEOUT
    subwf     TMR0
W
    btfss     STATUS
C
    
goto     judge2
    
;MOVLW    0x13
    
;MOVWF     0xa  
    call    Initial_Timer0
    incf     int_counter
F

judge2
    
;if (int_count >= INTERNAL_TMR0)
    
movlw     INTERNAL_TMR0
    subwf     int_counter
W
    btfss     STATUS
C
    
goto     loop1
    movlw     0x01    
GP0
    xorwf     GPIO
F
    clrf     int_counter
    incf     counter
F

    decfsz    counter
F
    
goto    loop1
loop2
    
goto    loop2

    END                       
end of program
//---------------------------------------------------------------------------

使用MPLAB IDE7.1 + MPASM + ICD2
compiler後出現錯誤訊息, 不知哪邊出問題, 請各位前輩高抬貴手, 指點一下.
Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.EXE" /q /p10F202 "main.asm" /l"main.lst" /e"main.err"
Warning[205] C:\MPLAB\TEST\PIC10F202\START8PULSE\MAIN.ASM 3 : Found directive in column 1. (list)
Warning[205] C:\MPLAB\TEST\PIC10F202\START8PULSE\MAIN.ASM 8 : Found directive in column 1. (__CONFIG)
Warning[205] C:\MPLAB\TEST\PIC10F202\START8PULSE\MAIN.ASM 19 : Found directive in column 1. (CBLOCK)
Warning[205] C:\MPLAB\TEST\PIC10F202\START8PULSE\MAIN.ASM 22 : Found directive in column 1. (ENDC)
Warning[205] C:\MPLAB\TEST\PIC10F202\START8PULSE\MAIN.ASM 46 : Found directive in column 1. (ORG)
Error[108] C:\MPLAB\TEST\PIC10F202\START8PULSE\MAIN.ASM 76 : Illegal character (
)
Error[108] C:\MPLAB\TEST\PIC10F202\START8PULSE\MAIN.ASM 77 : Illegal character (
)
Error[108] C:\MPLAB\TEST\PIC10F202\START8PULSE\MAIN.ASM 78 : Illegal character (
)
Halting build on first failure as requested.
BUILD FAILED: Thu Dec 22 18:25:04 2005

謝謝!

發表於: 2005/12/22 18:37
頂部


Re: 關於 PIC10F206 的 delay
#4
新會員
新會員


沒人知道嗎? 我正在等待答案.
Waiting~~~

發表於: 2005/12/22 18:31
頂部


Re: 關於 PIC10F206 的 delay
#5
新會員
新會員


您好:
除了用PIC KIT外, 是否可用ICD2寫入OSC校正值?
我用PIC10F202+MPLAB IDE 7.1+ICD2
pic10f202寫入一次, 工作正常, 但是抹除再寫入, 第二次以上就無法正常工作了, 而且0x1FF讀出來是0x000 或者是0x808.
MPLAB IDE Programer -> Settings -> Calibration Memory 有個選項 Allow ICD2 to program calibration memory, 我把它打勾並填入值(試圖修改回來), program target device時, 會出現錯誤訊息, 如下:
Programming Target...
ICDWarn0044: Target has an invalid calibration memory value (0x800). Continue?
ICDWarn0045: You have chosen to program a new calibration memory value. Doing so will destroy the existing calibration memory value. Do you wish to continue?
...Validating configuration fields
...Erasing Part
...Programming Program Memory (0x0 - 0x1FD)
...Calibration Memory
Verifying...
...Program Memory
ICD0161: Verify failed (MemType = Program, Address = 0x4, Expected Val = 0x909, Val Read = 0x800)
ICD0275: Programming failed.
MPLAB ICD 2 Ready
無法寫入PIC, 這是怎麼回事? 是IDE的bug嗎? 更新IDE版本, 可以解決問題嗎?

我用的是 HI-Tech C compiler, C內建組合語法如下
#asm
        
movwf   _OSCCAL            // update register with factory cal value     
        
bsf    _OSCCAL,0
    
#endasm

如果單獨用C language, 有辦法表示嗎?

Thanks!

發表於: 2005/12/21 11:37
頂部


Re: 關於 PIC10F206 的 delay
#6
新會員
新會員


我也很想知道, 如何讓timer0開始運作及停止?
目前正在用10F202遇到一些trouble.

另外位址0x1FF的地方是不是不能寫入?(內存Osciliator校正值)
萬一寫入此位址會怎樣, 可以復原嗎?

程式開始的第一行
movwf OSCCAL
如何用c language表示(因為用到W register)

謝謝!

發表於: 2005/12/20 14:01
頂部


PIC12F629使用ICD2如何進Debugger模式?
#7
新會員
新會員


大家好:
請問 一下, 我在使用MPLAB IDE + HI TECH C編輯程式時, 可以進Programmer模式燒錄, 而進Debugger模式時燒錄時卻有問題,如下:
MPLAB ICD 2 Ready
Resetting Target
Entering Debug Mode
...Programming GOTO 0x00 command
Resetting Target
MPLAB ICD 2 Ready
Entering Debug Mode
ICDWarn0015: Program memory has changed since last program operation? Continue with Debug operation?
Running Target
Entering Debug Mode
ICD0083: Target not in debug mode, unable to perform operation
ICD0069: Unable to run target Entering Debug Mode
MPLAB ICD 2 Ready

我使用內部Oscillator, Config設定如下:
Oscillator Internal RC No Clock
Watchdog Timer Off
Power Up Timer Off
Master Clear Enable External
Brown Out Detect Off
Code Protect Off
Data EE Read Protect Off

是因為使用內部OSC, 才導致無法debug嗎?
該如何解決?

謝謝!

發表於: 2005/9/9 20:03
頂部


為何PIC12F629 timer1誤差這麼大, 快吐血了!!!
#8
新會員
新會員


大家好(我一點也不好):
我用了一顆PIC12F629做計時器, 使用內部OSC 4MHz, GPIO2接LED, 程式如下:
參考http://www.microchip.com.tw/modules/n ... e=flat&order=ASC&start=10
#include <pic.h>

// 每50ms(0.05s)計數一次 
// (4Mhz/4) [1*(50000)] = 50mS (內部振盪器:4MHz, Prescale:1)
#define TMR1H_VALUE 256-(unsigned char)((4000000/4 * 0.05)/256)-1
#define TMR1L_VALUE 256-(unsigned char)(4000000/4 * 0.05) % 256 

#define WARNNING_LED    GPIO2

//**********************************
//* Function Prototype Declaration
//**********************************
void interrupt isr_Sevr void );
void Initial_Timer1Int(void);

// ================================================================
// **** Establish PIC12F629 Configuration Word
// **** == Internal Oscillator No Clock Mode
// **** == Watch-Dog Timer Off
// **** == Power Up Timer Off
// **** == MCLR Enable External
// **** == Brown-Out Detect Enabled
// **** == Code Protect Off
// **** == Data EE Read Protect Off
//__CONFIG  (INTRC_OSC_NOCLKOUT & WDT_OFF & PWRTE_OFF & MCLRE_EXT & BODEN_ON & CP_OFF & CPD_OFF);

unsigned long _50ms 0;
unsigned long _1s 0;
unsigned long _1m 0;
//---------------------------------------------------------------------------


//*********************************
//* program main()
//*********************************
void main(void)
{
    
// 校正內部Oscillator 4Mhz    
    
OSCCAL _READ_OSCCAL_DATA();

    
// Initial GPIO
    
GPIO 0;        // Init GPIO
    
CMCON 0x07;    // Set GP<2:0>(CM<2:0>) to digital IO
    
TRISIO 0b00000011;    // Set GP<1:0> as input and GP<2> as output

    
Initial_Timer1Int();

    while (
1)
    {
        if (
_50ms >= 20)    // 1秒
        
{
            
_50ms 0;
            
_1s++;
        }
        if (
_1s>=60)        // 1分鐘
        
{
            
_1s 0;
            
_1m++;
            
WARNNING_LED = !WARNNING_LED;
        }
    }
}
//---------------------------------------------------------------------------


//***********************************************
//*          Interrupt Service Routine            *       
//***********************************************
void interrupt isr_Sevr void )
{
    
//GIE = 0;        // INTCON<7> Disables all interrupts
    
if (TMR1IF)        // PIR1<0>
    
{
        
TMR1H TMR1H_VALUE;
        
TMR1L TMR1L TMR1L_VALUE;
        
TMR1IF 0;
        
_50ms++;
    }
    
//GIE = 1;        // INTCON<7> Enables all unmasked interrupts
}
//---------------------------------------------------------------------------


//***********************************************
//*         Initial Timer1 Interrupt
//***********************************************
void Initial_Timer1Int(void)
{
    
TMR1H TMR1H_VALUE;
    
TMR1L TMR1L_VALUE;
    
// Enable Timer1
    
T1CON 0b00000001;    // Enable Timer1, Internal Clock(Fosc/4), LP Oscillator is Off, 
                        // 1:1 Prescale Value, Timer1 is On ignore !T1G
    
    
TMR1IE 1;        // PIE1<0> Enable Timer1 Interrupt
    
PEIE 1;        // INTCON<6> Enables all unmasked peripheral interrupts
    
GIE 1;        // INTCON<7> Enables all unmasked interrupts
    
TMR1IF 0;        // PIR1<0> TMR1 register overflowed (must be cleared in software)
}

為何1分鐘就會快個0.5秒, 真傷腦筋

發表於: 2005/9/9 19:46
頂部


Re: 要如何設定12F/629之內部震盪?
#9
新會員
新會員


參照:

Ryang 寫道:
直接寫暫存器的位置。

asm("movwf 0x30");



OSCCAL位址不是0x90嗎?
還是只是舉例說明用法...

發表於: 2005/9/9 18:11
頂部


Re: 要如何設定12F/629之內部震盪?
#10
新會員
新會員


原來方法這麼多種, 了解了.
多謝^_^

發表於: 2005/9/9 18:08
頂部



(1) 2 »



:::

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

教育訓練中心

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