Re: unsigned char temp;如何將bit重新定義
|
||||
---|---|---|---|---|
新會員
|
to;版主
謝謝回應! 1..以mplabe sim有分配位置(0xff) 2..以icd2接至目標電路板則無分配位置,產生"reserved memory"
發表於: 2005/5/14 13:05
|
|||
|
PWM不能動作
|
||||
---|---|---|---|---|
新會員
|
//PIC18F1220
//全橋式輸出,INT0=0 then Autoshutdown //檢查RB7還是INPIT //ECCPASE 並未=1 IRCF0 = 1; // Used to set intrc speed to 8 MHz IRCF1 = 1; // Used to set intrc speed to 8 MHz IRCF2 = 1; // Used to set intrc speed to 8 MHz TRISB = 0xff; PR2 = 0x3F; // Sets PWM Period at 31.2 kHz CCP1CON = 0b01001110; // Full bridge PWM forward,P1M0=1, ECCPAS = 0b11001100; // INT0 pin low causes shutdown,Pins A/C=1,B/D=0 PWM1CON =0x0; // b7=0→clear ECCPASE ,b7=1→autorestart TMR2IF = 0; T2CON = 0; // TMR2 Off with no prescale CCPR1L = 0x1F; // Sets Duty Cycle to TMR2ON = 1; // Start Timer2 while(TMR2IF) ; // wait until TMR2 overflows(first period) PORTA = 0; TRISA = 0b00111111; // Set RA7 and RA6 as outputs PORTB = 0; TRISB = 0b00110011; // Set RB7,RB6,RB3,RB2 outputs RBPU = 1; // RB pull up resister ADCON0 = 1; // Use Vdd as Ref,Channel select AN0,ADON ADCON1 = 0b11110000; // Configure AN0~AN3 as analog ADCON2 = 0b10000101; // Right j T0CS = 0; // Timer0 as timer not a counter TMR0 = TMR0base; // Preload value PSA = 0; // Prescaler to Timer0 T0PS0 = 0; // Prescale to 32 => 1024 Hz T0PS1 = 0; T0PS2 = 1; INTCON = 0; PIE1 = 0; TMR0IE = 1; // Enable Timer0 int
發表於: 2005/5/3 10:34
|
|||
|
Re: eeprom write(mplab sim=ok,icd2 "pic18f1220" not ok)
|
||||
---|---|---|---|---|
新會員
|
Thank you!
解決了!
發表於: 2005/5/2 9:04
|
|||
|
eeprom write(mplab sim=ok,icd2 "pic18f1220" not ok)
|
||||
---|---|---|---|---|
新會員
|
//hitec c18,pic1220 #include <pic18.h> #include <pic18f1220.h> #include <math.h> #include <stdlib.h> .. ... .... .... ... void EE_W(unsigned char address, int data) { union { unsigned int i; unsigned char b[2]; } etemp; etemp.i = data; //Low EEADR = address; EEDATA = etemp.b[0]; EEPGD = 0; CFGS = 0; WREN= 1; GIE = 0; EECON2 = 0x55; EECON2 = 0xAA; WR = 1; while(WR) ; //Hi byte EEADR++; EEDATA = etemp.b[1]; EECON2 = 0x55; EECON2 = 0xAA; WR = 1; while(WR) ; WREN= 0; GIE = 1; } //configbit= //osc=int rc,ra7:6=io //low voltage program=disable //data eeprom code protect=disable //data eeprom write protect=disable
發表於: 2005/4/30 13:24
|
|||
|
GPIO<5:4>無法設成'OUTPUT'
|
||||
---|---|---|---|---|
新會員
|
片段
*************** list p=12f629 include "c:\program files\mplab ide\mchip_tools\p12f629.inc" __CONFIG _CP_ON&_WDT_OFF&_MCLRE_OFF&_INTRC_OSC_NOCLKOUT&_PWRTE_ON&_BODEN_ON ;***** VARIABLE DEFINITIONS ***** CBLOCK 0x20 clkcount W_TEMP ; STATUS_TEMP ; endc ; ;************************ ORG 0x000 ; coding begins here bsf STATUS,RP0 call 3FFh movwf OSCCAL goto _MAIN ;**************************** ;Interrupt Vector interpt: ORG 0x04 movwf W_TEMP ; ; swapf STATUS,W ; bcf STATUS,RP0 ; ; movwf STATUS_TEMP ; NOP SER_EXIT: bcf STATUS,RP0 ; swapf STATUS_TEMP,W ; ; movwf STATUS ; swapf W_TEMP,F ; swapf W_TEMP,W ; retfie ;**************************** _MAIN: call init _doing: nop goto _doing ;************************** init: ;在PAGE0 bcf STATUS,RP0 ;Bank 0 clrf GPIO ;Init GPIO movlw 07h ;Set GP<2:0> to movwf CMCON ;digital IO(Not ADC IN) bcf T1CON,T1OSCEN bcf T1CON,TMR1GE bsf STATUS,RP0 ;Bank 1 movlw b'11110000' ;wake pull-ups movwf WPU ;clrf ANSEL ;digital I/O movlw b'11001111' movwf TRISIO movlw b'10000000' ; movwf OPTION_REG movlw b'00001111' movwf IOCB ;pin on change bcf STATUS,RP0 NOP bsf INTCON,PEIE bsf INTCON,T0IE bsf INTCON,GIE return END
發表於: 2004/6/13 18:29
|
|||
|