Skip to content

Instantly share code, notes, and snippets.

@TG9541
Last active December 24, 2019 21:24
Show Gist options
  • Save TG9541/666e421f80dfbc6cca5957238175bf08 to your computer and use it in GitHub Desktop.
Save TG9541/666e421f80dfbc6cca5957238175bf08 to your computer and use it in GitHub Desktop.
Notes for DCDC-MH
Pin	STM	 Connected to
1	PD4	 dig 1
2	PD5	 seg A
3	PD6	 seg F
4	NRST  R - VSS
5	PA1	 seg DP
6	PA2	 seg D
7	VSS	 GND
8	Vcap	 Cap
9	VDD	 +3.6V
10	PA3	 seg E
11	PB5	 dig 3
12	PB4	 dig 2
13	PC3	 seg C
14	PC4	 Ain "Vin" (analog)
15	PC5	 seg G
16	PC6	 LED "IN"
17	PC7	 seg B
18  PD1/SWIM  S1 (to GND)
19	PD2  LED "OUT"
20	PD3	 Ain "Vout" (analog)
@TG9541
Copy link
Author

TG9541 commented Dec 24, 2019

Pin     LED      Connected to
1       E        PA3
2       D        PA2
3       DP       PA1
4       C        PC3
5       G        PC5
(6)     -
7       B        PC7
8       dig3     PB5
9       dig2     PB4
10      F        PD6
11      A        PD5
12      dig1     PD4

@TG9541
Copy link
Author

TG9541 commented Dec 24, 2019

boardcore.inc (changes for W1209 file)

BOARDINIT:
        ; DCDC-MH STM8S003F3 init GPIO
        MOV     PA_DDR,#0b00001110 ; E,D,DP 
        MOV     PA_CR1,#0b00001110
        MOV     PB_DDR,#0b00110000 ; d3,d2
        MOV     PB_CR1,#0b00110000
        MOV     PC_DDR,#0b11101000 ; B,Li,G,Vi,C
        MOV     PC_CR1,#0b11101000 ; 
        MOV     PD_DDR,#0b01110100 ; F,A,dig1,Vo,Lo
        MOV     PD_CR1,#0b01110110 ; S1 
;       LED_MPX driver ( -- )
;       Output bit pattern in A to 7S-LED digit hardware

LED_MPX:
        BSET    PD_ODR,#4       ; Digit .3..
        BSET    PB_ODR,#4       ; Digit ..2.
        BSET    PB_ODR,#5       ; Digit ...1

        LD      A,TICKCNT+1
        AND     A,#0x03         ; 3 digits MPX

        JRNE    1$
        BRES    PD_ODR,#4       ; digit .3..
        JRA     3$

1$:     CP      A,#1
        JRNE    2$
        BRES    PB_ODR,#4       ; digit ..2.
        JRA     3$

2$:     CP      A,#2
        JRNE    4$
        BRES    PB_ODR,#5       ; digit ...1
        ; fall through

3$:     CLRW    X
        LD      XL,A
        LD      A,(LED7LAST-2,X)

        ; DCDC-MH 7S LED display row
        ; bit 76453210 input (parameter A)
        ;  PA ....EDP.
        ;  PC B.G.C...
        ;  PD .FA.....
        RRC     A
        BCCM    PD_ODR,#5       ; A
        RRC     A
        BCCM    PC_ODR,#7       ; B
        RRC     A
        BCCM    PC_ODR,#3       ; C
        RRC     A
        BCCM    PA_ODR,#2       ; D
        RRC     A
        BCCM    PA_ODR,#3       ; E
        RRC     A
        BCCM    PD_ODR,#6       ; F
        RRC     A
        BCCM    PC_ODR,#5       ; G
        RRC     A
        BCCM    PA_ODR,#1       ; DP

4$:     RET
        RamWord OUTPUTS         ; "OUT", e.g. relays, LEDs, etc. (16 bit)

;       OUT!  ( c -- )
;       Put c to board outputs, storing a copy in OUTPUTS
        .dw     LINK

        LINK =  .
        .db     (4)
        .ascii  "OUT!"
OUTSTOR:
        INCW    X
        LD      A,(X)
        INCW    X
AOUTSTOR:
        LD      OUTPUTS+1,A
        RRC     A
        BCCM    PC_ODR,#6       ; LED In
        RRC     A
        BCCM    PD_ODR,#2       ; LED Out
        RET
;       BKEY  ( -- c )     ( TOS STM8: -- A,Z,N )
;       Read board key state as a bitfield
        .dw     LINK

        LINK =  .
        .db     (4)
        .ascii  "BKEY"
BKEY:
        ; Keys "S1" (1) on PD1
        LD      A,PD_IDR
        SRA     A
        CPL     A
        AND     A,#0x01
        JP      ASTOR

;       BKEYC  ( -- c )   ( TOS STM8: -- A,Z,N )
;       Read and translate board dependent key bitmap into char

BKEYCHAR:
        CALLR   BKEY
        JREQ    1$
        ADD     A,#'@'
        LD      (1,X),A
1$:     RET

globconf.inc (changes for W1209 file):

; STM8 eForth Global Configuration File
; Config for DCDC converter with voltmeter "MH"
; Clock: HSI (no crystal)

        HALF_DUPLEX      = 0    ; Use UART in half duplex mode
        HAS_TXUART       = 0    ; No UART TXD, word TX!
        HAS_RXUART       = 0    ; No UART RXD, word ?RX
        HAS_RXSIM        = 1    ; Enable RxD via GPIO/TIM4, word ?RXGP
        HAS_TXSIM        = 1    ; Like HAS_RXSIM, word TXGP!, use for console if > HAS_TXUART
        PSIM     = PORTD        ; Port for UART simulation
        PNRX             = 1    ; Port GPIO# for HAS_RXDSIM
        PNTX             = 1    ; Port GPIO# for HAS_TXDSIM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment