Your SlideShare is downloading. ×
  • Like
Aldebaran.asm
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Aldebaran.asm

  • 325 views
Published

このソースコードは …

このソースコードは
クリエイティブ・コモンズ
表示2.1日本 ライセンス
の下に提供致します。

Published in Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
325
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
2
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. ;------------------------------------; ◗Aldebaran㗗ã—ã—°ã—©ã—; 佗旗日旗72012.12.12 Y.Yamashiro; 旴旰日旗72012.12.26 Y.Yamashiro;; ◗旴旰履æ´; Ver.0.1 2012.12.12 Y.Yamashiro㗗INCLUDE,__CONFIG㗗佗旗; Ver.1.0 2012.12.24 Y.Yamashiro㗗痹痯確誗㗗EEPROM託时嗗確誗; Ver.1.5 2012.12.25 Y.Yamashiro㗗㗽㗼㗹㗳㗼㗗㗗旴形; Ver.C83 2012.12.26 Y.Yamashiro㗗嗗嗺;;------------------------------------ LIST P=PIC12F675 INCLUDE "P12F675.INC" __CONFIG _CP_OFF & _CPD_OFF & _BODEN_ON & _MCLRE_ON & _WDT_ON & _PWRTE_ON& _INTRC_OSC_NOCLKOUT;------------------------------------ CBLOCK 0x20TIMER_TMP ; 㗿㗤㗗痨㗫㗦㗳㗿COLD_START_TMP ; 㗳㗼㗫㗗㗹㗿㗼㗗旗㗦㗧㗤㗗痨㗫㗦㗳㗿DUTY_RED ; 赤藲㗮㗗㗥㗼㗗㗣DUTY_GREEN ; 緗藲㗮㗗㗥㗼㗗㗣DUTY_BLUE ; 闗藲㗮㗗㗥㗼㗗㗣DUTY_TMP ; 3㗗㗩㗬㗫PWM嗨旗痗旗痨DUTY_RED_TMP ;DUTY_GREEN_TMP ;DUTY_BLUE_TMP ;OUTPUT_TMP ;CHECK_PSW_PAST ; 㗗㗗㗷㗥㗹㗤㗗㗗嗥嗗㗪㗳㗰㗗㗗㗗㗡CURRENT_PRESET ; 痾嗨㗮㗗㗪㗻㗗㗗No.TOTAL_PRESET ; 緗㗗㗪㗻㗗㗗旰SET_COLOR_TMP ; 㗗㗪㗻㗗㗗No.->㗢㗗㗬㗹夗旗痨WRITE_EEPROM_DATA ; EEPROM旸㗗込㗿痨ALDEBARAN_SETTING ; Aldebaranè¨å®— ENDCLED_RED EQU GPIO1LED_GREEN EQU GPIO2LED_BLUE EQU GPIO0PUSH_SW EQU GPIO4MASTER_DUTY EQU D19;------------------------------------ ; EEPROM DATA ORG 02100H ; 㗗㗪㗻㗗㗗託述(4bytes㗧丗絗,R,G,B,X) ; 嗗藲0㗗20㗧è¨å®—嗯藽㗗 DE D20,D00,D00,D00 ; 赤 DE D15,D06,D08,D00 ; 桗 DE D20,D09,D00,D00 ; 橗 DE D20,D16,D00,D00 ; 黗 DE D00,D20,D00,D00 ; 緗 DE D00,D00,D20,D00 ; 闗 DE D10,D00,D10,D00 ; ç´« DE D15,D15,D08,D00 ; 痽 ORG 0217DH DE B00000001 ; 7D:㗢㗫㗗㗗㗩㗳è¨å®— DE D00 ; 7E:旗絗㗗㗪㗻㗗㗗No. DE D07 ; 7F:緗㗗㗪㗻㗗㗗旰(0to30);------------------------------------ ORG 0 NOP CLRWDT
  • 2. GOTO INITIALIZE NOP NOP NOP NOP NOP GOTO INTERRUPT;------------------------------------; 嗲㗗込㗿痺痗旗7痰常亗旗㗨嗤æ—ã——INTERRUPT BANKSEL GPIO CLRF GPIOINTERRUPT_LP ; 痡闗㗫㗼㗗◗WDT㗪㗻㗗㗗㗗 GOTO INTERRUPT_LP;------------------------------------; 嗗旗è¨å®—INITIALIZE; 闻嗧宗宗痨㗮㗦㗧㗤㗗(紗250ms)㗗嗥㗗㗗 CALL COLD_START; 㗗㗪㗹㗱㗼㗩㗯WDT痨(1:128); 嗗藵㗗㗫㗢㗗㗗(GPIO)㗗旗嗹 BANKSEL OPTION_REG MOVLW B00101111 MOVWF OPTION_REG; 嗗藵㗗㗫㗢㗗㗗(4,5)㗗旗嗹 BANKSEL WPU MOVLW B00110000 MOVWF WPU; 嗗藵㗳㗳㗗㗬㗼㗿㗗OFF BANKSEL CMCON MOVLW B00000111 MOVWF CMCON; 嗨㗦㗗㗗㗸㗿㗫嗥嗺嗗㗫㗗㗗 BANKSEL ANSEL CLRF ANSEL; 嗥嗺嗗è¨å®— BANKSEL TRISIO MOVLW B00111000 MOVWF TRISIO; 㗗㗼㗗㗮痶旗㗗嗗旗嗤㗫 BANKSEL GPIO CLRF GPIO; 夗旰嗗旗嗗; CLRF DUTY_RED; CLRF DUTY_GREEN; CLRF DUTY_BLUE; CLRF CURRENT_PRESET; CLRF FLAG_SAVE_LAST_PRESET MOVLW 0xFF MOVWF CHECK_PSW_PAST; è¨å®—èªã—¿å—ºã—— CALL LOAD_SETTING CALL SET_COLOR; è¨å®—絗亗 GOTO MAIN;------------------------------------; 㗡㗤㗳嗦痗MAIN CLRWDT BANKSEL GPIO CALL CHECK_PSW CALL MAIN_OUTPUT GOTO MAIN
  • 3. ;------------------------------------; è¨å®—èªã—¿å—ºã——LOAD_SETTING BANKSEL GPIO MOVLW 0x7D CALL READ_EEPROM MOVWF ALDEBARAN_SETTING BTFSS ALDEBARAN_SETTING,0 GOTO LOAD_SETTING_PRESET_NOSAVE GOTO LOAD_SETTING_PRESET_SAVELOAD_SETTING_PRESET_NOSAVE CLRF CURRENT_PRESET GOTO LOAD_SETTING_PRESET_TOTALLOAD_SETTING_PRESET_SAVE MOVLW 0x7E CALL READ_EEPROM MOVF CURRENT_PRESET,W GOTO LOAD_SETTING_PRESET_TOTALLOAD_SETTING_PRESET_TOTAL MOVLW 0x7F CALL READ_EEPROM MOVWF TOTAL_PRESET RETURN;------------------------------------; 藲㗗è¨å®—SET_COLOR BANKSEL GPIO MOVF CURRENT_PRESET,W MOVWF SET_COLOR_TMP RLF SET_COLOR_TMP,F RLF SET_COLOR_TMP,W ANDLW B01111100 MOVWF SET_COLOR_TMPSET_COLOR_READ_RED MOVF SET_COLOR_TMP,W ADDLW B00000000 CALL READ_EEPROM MOVWF DUTY_REDSET_COLOR_READ_GREEN MOVF SET_COLOR_TMP,W ADDLW B00000001 CALL READ_EEPROM MOVWF DUTY_GREENSET_COLOR_READ_BLUE MOVF SET_COLOR_TMP,W ADDLW B00000010 CALL READ_EEPROM MOVWF DUTY_BLUE; 尗日㗮旡張痨;SET_COLOR_READ_KAKUCHO; MOVF SET_COLOR_TMP,W; ADDLW B00000011; CALL READ_EEPROM; MOVWF DUTY_BLUE RETURN;------------------------------------; EEPROMèªã—¿è¾¼ã—¿READ_EEPROM BANKSEL EEADR MOVWF EEADR BSF EECON1,RD MOVF EEDATA,W BANKSEL GPIO RETURN
  • 4. ;------------------------------------; EEPROM旸㗗込㗿WRITE_EEPROM BANKSEL GPIO CLRF GPIO BANKSEL EEADR MOVWF EEADR MOVF WRITE_EEPROM_DATA,W MOVWF EEDATAWRITE_EEPROM_GO BSF EECON1,WREN BCF INTCON,GIE MOVLW 0x55 MOVWF EECON2 MOVLW 0xAA MOVWF EECON2 BSF EECON1,WRWRITE_EEPROM_LP BTFSC EECON1,WR GOTO WRITE_EEPROM_LP BANKSEL GPIO RETURN;------------------------------------; 㗗㗗㗷㗥㗹㗤㗗㗗㗗旼㗗㗗㗦㗗㗗㗗7CHECK_PSW BANKSEL GPIOCHECK_PSW_LOTATE RLF CHECK_PSW_PAST,F BTFSC GPIO,PUSH_SW BSF CHECK_PSW_PAST,0 BTFSS GPIO,PUSH_SW BCF CHECK_PSW_PAST,0CHECK_PSW_JUDGE MOVF CHECK_PSW_PAST,W XORLW B00000011 BTFSC STATUS,Z GOTO CHECK_PSW_YES RETURNCHECK_PSW_YES INCF CURRENT_PRESET,F MOVF CURRENT_PRESET,W SUBWF TOTAL_PRESET,W BTFSS STATUS,C CLRF CURRENT_PRESET CALL SET_COLOR; 旗得㗫使㗣㗗㗗㗪㗻㗗㗗㗗俗å—㗗㗦㗗㗗㗗7 BTFSS ALDEBARAN_SETTING,0 RETURN MOVF CURRENT_PRESET,W MOVWF WRITE_EEPROM_DATA MOVLW 0x7E CALL WRITE_EEPROM RETURN;------------------------------------; LED㗗痹痯㗗㗗㗗嗦痗MAIN_OUTPUT BANKSEL GPIO MOVLW MASTER_DUTY MOVWF DUTY_TMP MOVF DUTY_RED,W MOVWF DUTY_RED_TMP MOVF DUTY_GREEN,W MOVWF DUTY_GREEN_TMP MOVF DUTY_BLUE,W
  • 5. MOVWF DUTY_BLUE_TMP;--------------------; 㗫㗼㗗MAIN_OUTPUT_LP CLRF OUTPUT_TMP;----------; 赤藲㗗嗺嗗MAIN_OUTPUT_LP_RED MOVF DUTY_RED_TMP,W BTFSC STATUS,Z GOTO MAIN_OUTPUT_LP_RED_END DECFSZ DUTY_RED_TMP,F GOTO MAIN_OUTPUT_LP_RED_ON GOTO MAIN_OUTPUT_LP_RED_OFFMAIN_OUTPUT_LP_RED_ON BSF OUTPUT_TMP,LED_RED NOP NOP GOTO MAIN_OUTPUT_LP_GREENMAIN_OUTPUT_LP_RED_OFF BCF OUTPUT_TMP,LED_RED GOTO MAIN_OUTPUT_LP_GREENMAIN_OUTPUT_LP_RED_END NOP NOP NOP NOP NOP NOP GOTO MAIN_OUTPUT_LP_GREEN;----------; 緗藲㗗嗺嗗MAIN_OUTPUT_LP_GREEN MOVF DUTY_GREEN_TMP,W BTFSC STATUS,Z GOTO MAIN_OUTPUT_LP_GREEN_END DECFSZ DUTY_GREEN_TMP,F GOTO MAIN_OUTPUT_LP_GREEN_ON GOTO MAIN_OUTPUT_LP_GREEN_OFFMAIN_OUTPUT_LP_GREEN_ON BSF OUTPUT_TMP,LED_GREEN NOP NOP GOTO MAIN_OUTPUT_LP_BLUEMAIN_OUTPUT_LP_GREEN_OFF BCF OUTPUT_TMP,LED_GREEN GOTO MAIN_OUTPUT_LP_BLUEMAIN_OUTPUT_LP_GREEN_END NOP NOP NOP NOP NOP NOP GOTO MAIN_OUTPUT_LP_BLUE;----------; 闗藲㗗嗺嗗MAIN_OUTPUT_LP_BLUE MOVF DUTY_BLUE_TMP,W BTFSC STATUS,Z GOTO MAIN_OUTPUT_LP_BLUE_END DECFSZ DUTY_BLUE_TMP,F GOTO MAIN_OUTPUT_LP_BLUE_ON GOTO MAIN_OUTPUT_LP_BLUE_OFF
  • 6. MAIN_OUTPUT_LP_BLUE_ON BSF OUTPUT_TMP,LED_BLUE NOP NOP GOTO MAIN_OUTPUT_LP_DEADMAIN_OUTPUT_LP_BLUE_OFF BCF OUTPUT_TMP,LED_BLUE GOTO MAIN_OUTPUT_LP_DEADMAIN_OUTPUT_LP_BLUE_END NOP NOP NOP NOP NOP NOP GOTO MAIN_OUTPUT_LP_DEADMAIN_OUTPUT_LP_DEAD MOVF OUTPUT_TMP,W MOVWF GPIO DECFSZ DUTY_TMP,F GOTO MAIN_OUTPUT_LP RETURN;------------------------------------; 簡旗㗿㗤㗗㗼TIMER BANKSEL GPIO MOVWF TIMER_TMP MOVF TIMER_TMP,W BTFSC STATUS,Z RETURNTIMER_LP NOP DECFSZ TIMER_TMP,F GOTO TIMER_LP RETURN;------------------------------------; 㗳㗼㗫㗗㗹㗿㗼㗗旗㗫闻嗧宗宗㗾㗧得㗤COLD_START BANKSEL GPIO MOVLW 0xFF MOVWF COLD_START_TMPCOLD_START_LP MOVLW 0xFF CALL TIMER DECFSZ COLD_START_TMP,F GOTO COLD_START_LP RETURN;------------------------------------ END