summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2012-06-20 00:34:41 +0000
committerChristian Pointner <equinox@mur.at>2012-06-20 00:34:41 +0000
commitbb53e1f4c48a062d822aecbe02694dc5959faa30 (patch)
treed93e3edc1ca4d807605ed5e75b8abe8949076974 /software
parentadded check for CMD_READ (diff)
adc sampling starts now via timer1 and ccp4 (less jitter)
some cleanup git-svn-id: https://svn.spreadspace.org/mur.sat@541 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r--software/idm-test/idm-test.c7
-rw-r--r--software/idm/idm.asm81
2 files changed, 51 insertions, 37 deletions
diff --git a/software/idm-test/idm-test.c b/software/idm-test/idm-test.c
index 89363e6..d725691 100644
--- a/software/idm-test/idm-test.c
+++ b/software/idm-test/idm-test.c
@@ -43,7 +43,7 @@
/* Global I/O Buffers: */
static RingBuffer_t SPItoUSB_Buffer;
-static uint8_t SPItoUSB_Buffer_Data[8];
+static uint8_t SPItoUSB_Buffer_Data[64];
/** LUFA CDC Class driver interface configuration and state information. This structure is
* passed to all CDC Class driver functions, so that multiple instances of the same class
@@ -132,18 +132,17 @@ void IDM_ReadData(void)
_delay_us(100);
SPI_SendByte('r');
- _delay_us(50);
+ _delay_us(30);
uint8_t int_state = (INT_PIN & (1<<INT));
while(!int_state) {
uint8_t ReceivedByte = SPI_ReceiveByte();
RingBuffer_Insert(&SPItoUSB_Buffer, ReceivedByte);
if(RingBuffer_IsFull(&SPItoUSB_Buffer))
break;
- _delay_us(30);
+ _delay_us(25);
int_state = (INT_PIN & (1<<INT));
}
- _delay_us(100);
SPI_CS_PORT |= (1<<CS);
led_off();
}
diff --git a/software/idm/idm.asm b/software/idm/idm.asm
index b0bce9a..9cbaf41 100644
--- a/software/idm/idm.asm
+++ b/software/idm/idm.asm
@@ -67,6 +67,7 @@ BUF_ENDL EQU H'00BF'
;; variables
;; all Pages
CMD EQU H'0070'
+TMP EQU H'0071'
FLAGS EQU H'007F'
@@ -115,13 +116,16 @@ inc_fsr_end
;; Interrupts
org .4
movlb b'00000000'
- btfsc PIR1,TMR2IF
- goto int_tmr2
+if DEBUG == 1
+ bsf SPEAKER
+endif
btfsc PIR1,SSP1IF
goto int_spi
+ btfsc PIR1,ADIF
+ goto int_adc
retfie
- ;; void timer2Interrupt()
+ ;; void adcInterrupt()
;; {
;; static char value = 0;
;; if (!overrun) {
@@ -129,20 +133,17 @@ inc_fsr_end
;; wbuf_next();
;; }
;; }
-int_tmr2
- bcf PIR1,TMR2IF
+int_adc
+ bcf PIR1,ADIF
btfsc OVERRUN
- goto int_end
- movlb b'00000001'
- bsf ADCON0,GO
-
-int_tmr2_adcon
- btfsc ADCON0,GO
- goto int_tmr2_adcon
- movf ADRESH,w
+ retfie
+ ;; movlb b'00000001'
+ ;; movf ADRESH,w
+ movf TMP,w
movwf INDFW
+ incf TMP,f
call wbuf_next
- goto int_end
+ goto int_fsr_norestore
;; void sspInterrupt()
;; {
@@ -171,25 +172,25 @@ int_spi
goto int_spi_r
;; other commands
bcf CMD_READ
- goto int_end
+ retfie
int_spi_0
btfss CMD_READ
- goto int_end
+ retfie
call rbuf_next
movf INDFR,w
btfss UNDERRUN
movwf SSP1BUF
- goto int_end
+ goto int_fsr_norestore
int_spi_r
movf INDFR,w
btfss UNDERRUN
movwf SSP1BUF
bsf CMD_READ
- ;; goto int_end
-
-int_end
+ retfie
+
+int_fsr_norestore
movlb .31
movf FSR0H,w
movwf FSR0H_SHAD
@@ -321,6 +322,14 @@ endif
;; -------------------------------------
;; INIT
init
+ ;; BANK 6
+ movlb b'00000110'
+ clrf CCPR4H
+ movlw .124
+ movwf CCPR4L
+ movlw b'00001011'
+ movwf CCP4CON
+
;; BANK 4
movlb b'00000100'
movlw b'01000000'
@@ -352,17 +361,20 @@ endif
movwf ADCON1
movlw b'00001101' ; AN3, ADC On
movwf ADCON0
- movlw b'00001010' ; SSPIE,TMR2IE
+ movlw b'01001000' ; ADIE,SSPIE
movwf PIE1
- bcf OPTION_REG,NOT_WPUEN
-
+ movlw b'01011111' ; Enable Pull UPs, disable T0CKI
+ movwf OPTION_REG
+
;; BANK 0
movlb b'00000000'
movlw .124 ; 8 kHz @ 16MHz
movwf PR2
- clrf TMR2 ; reset TMR2
- movlw b'00000101' ; Postscaler 1:1,Timer Off,Prescaler 1:4
- movwf T2CON
+ clrf TMR1H ; reset TMR1
+ clrf TMR1L
+ movlw b'00100000' ; Source Fosc/4, Prescaler 1:4, LP-Osc off, Sync, Timer off
+ movwf T1CON
+ clrf T1GCON
clrf PIR1 ; reset all used interupt flags
movlw b'01000000' ; PEIE
movwf INTCON
@@ -370,22 +382,25 @@ endif
bcf FILTER_EN
call buf_init
+ clrf TMP
+
bsf INTCON,GIE
;; -------------------------------------
;; MAINLOOP
main
if DEBUG == 1
+ bcf SPEAKER
btfss DBG0
- goto enable_t2
+ goto enable_t1
- btfsc T2CON,TMR2ON
- bcf T2CON,TMR2ON
+ btfsc T1CON,TMR1ON
+ bcf T1CON,TMR1ON
goto main
-
-enable_t2
- btfss T2CON,TMR2ON
- bsf T2CON,TMR2ON
+
+enable_t1
+ btfss T1CON,TMR1ON
+ bsf T1CON,TMR1ON
endif
goto main