Skip to content

Instantly share code, notes, and snippets.

mipsparc mipsparc

Block or report user

Report or block mipsparc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mipsparc
mipsparc / adding_up_to_16.asm
Created May 25, 2018
1から16まで足していくだけのPIC向けアセンブリ
View adding_up_to_16.asm
ORG 0
RAMTOP
CLRF 0x20
CLRW
CALC
INCF 0x20
ADDWF 0x20, 0
BTFSS 0x20, 4
@mipsparc
mipsparc / scroll.asm
Created May 25, 2018
0x20に入ったビットがスクロールするだけのPIC向けアセンブリ
View scroll.asm
ORG 0
RAMTOP
CLRF 0x20
INCF 0x20, 1
LOOP
RLF 0x20, 1
GOTO LOOP
@mipsparc
mipsparc / pwm_controller.c
Created May 19, 2018
PWM制御鉄道模型コントローラの試作品の制御用PIC16F1向けプログラム。シリアルで入力されたDuty ratioで駆動する。Microchip MCCで生成されたハードウェア制御用メソッドを呼び出している
View pwm_controller.c
#include "mcc_generated_files/mcc.h"
#include <stdio.h>
void move(unsigned char direction)
{
if (direction == 1) {
PWM1_DutyCycleSet(639);
PWM1_LoadBufferSet();
} else {
@mipsparc
mipsparc / mascon_read.c
Last active Dec 2, 2018
DE10/DE15に使用されるMC45A主幹制御器などからノッチを読み取るやつ(PIC16F1579向け)
View mascon_read.c
// PIC16F1579 Configuration Bit Settings
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator; I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
@mipsparc
mipsparc / serialrx.c
Created Apr 13, 2018
PIC16F1579向け UARTで受信するテスト。RCREGbits.RCREGって書き方、完全に思いつかなかった
View serialrx.c
// PIC16F1579 Configuration Bit Settings
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator; I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
@mipsparc
mipsparc / meter_increment.c
Created Apr 11, 2018
ソフトウェアPWMでちょっとずつメーターが進んでいくテスト
View meter_increment.c
// PIC16F1579 Configuration Bit Settings
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator; I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
@mipsparc
mipsparc / serialtx.c
Created Apr 11, 2018
USARTで送信するテスト PIC16F1579向け
View serialtx.c
// PIC16F1579 Configuration Bit Settings
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator; I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
@mipsparc
mipsparc / door_led_indicator.c
Last active Apr 10, 2018
E233系ドア上ランプをイメージして、接点状態が変化すると0.3秒点滅を5回繰り返すPIC16F677向けCプログラム
View door_led_indicator.c
// CONFIG
#pragma config FOSC = INTRCCLK // Oscillator Selection bits (INTOSC oscillator: CLKOUT function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Selection bits (BOR enabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
@mipsparc
mipsparc / renamedirs.sh
Created Aug 5, 2017
renamedirs.txtにあるディレクトリのそれぞれ1番最初にあるJPEGファイルの撮影年をディレクトリ名に付加する
View renamedirs.sh
#!/bin/bash
cat renamedirs.txt | while read DIRN
do
FILENAME=`ls -1 $DIRN | sed -n '1p'`
YEAR=`echo ${DIRN}/${FILENAME} | python3 photodir_year.py`
echo "renaming ${DIRN}"
mv $DIRN ${DIRN}_${YEAR}
done
@mipsparc
mipsparc / exif_year.py
Created Aug 5, 2017
標準入力で与えられたファイル名のJPEGファイルのEXIF情報を読み込み、撮影された年を標準出力で返す
View exif_year.py
#/usr/bin/env python3
from PIL import Image
from datetime import datetime
imgname = input();
img = Image.open(imgname)
#DateTimeOriginal のExif tag ID
taken_datetime_exif = img._getexif()[0x9003]
You can’t perform that action at this time.