diff options
author | Christian Pointner <equinox@mur.at> | 2012-05-31 21:32:20 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2012-05-31 21:32:20 +0000 |
commit | f7a1d2e9cdbb4f4d4f0c7712803d5abd34f55763 (patch) | |
tree | cb24f74e0424d1d9400de686b66cfdc3e5f5d785 /software | |
parent | cleanup (diff) |
some timing test for idm communication (not working yet - hardware probs?)
git-svn-id: https://svn.spreadspace.org/mur.sat@501 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r-- | software/idm-test/idm-test.c | 8 | ||||
-rw-r--r-- | software/idm/idm.asm | 50 |
2 files changed, 41 insertions, 17 deletions
diff --git a/software/idm-test/idm-test.c b/software/idm-test/idm-test.c index 0de977f..c72ab91 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[128];
+static uint8_t SPItoUSB_Buffer_Data[8];
/** 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
@@ -104,7 +104,7 @@ void SetupHardware(void) TCCR0B = (1 << CS02);
- SPI_Init(SPI_SPEED_FCPU_DIV_4 | SPI_MODE_MASTER | SPI_ORDER_MSB_FIRST |
+ SPI_Init(SPI_SPEED_FCPU_DIV_16 | SPI_MODE_MASTER | SPI_ORDER_MSB_FIRST |
SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING);
SPI_CS_DDR |= (1<<CS);
SPI_CS_PORT |= (1<<CS);
@@ -129,17 +129,21 @@ void IDM_ReadData(void) {
led_on();
SPI_CS_PORT &= ~(1<<CS);
+ _delay_us(100);
SPI_SendByte('r');
+ _delay_us(50);
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);
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 ef48aaf..d2d68bc 100644 --- a/software/idm/idm.asm +++ b/software/idm/idm.asm @@ -32,7 +32,9 @@ ;; DEFINES CNT0 EQU H'0020' CNT1 EQU H'0021' - +CNT2 EQU H'0022' +TMP EQU H'0023' + ;; ------------------------------------- ;; OFFSET org .0 @@ -48,7 +50,10 @@ CNT1 EQU H'0021' int_spi bsf PORTA,7 - nop + bcf PIR1,SSP1IF + incf TMP,f + movf TMP,w + movwf SSP1BUF bcf PORTA,7 retfie @@ -82,7 +87,11 @@ init movwf TRISA movlw b'01110011' movwf TRISB - movlw b'01011000' +; movlw b'01011000' ; 1 MHz +; movlw b'01100000' ; 2 MHz +; movlw b'01101000' ; 4 MHz +; movlw b'01110000' ; 8 MHz + movlw b'01111000' ; 16 MHz movwf OSCCON movlw b'00001000' movwf PIE1 @@ -94,25 +103,36 @@ init movwf INTCON bcf PORTA,7 + bcf PORTB,3 + + clrf TMP + ;; ------------------------------------- ;; MAINLOOP main - movlw .50 - movwf CNT0 +;; movlw .255 +;; movwf CNT0 -outer - movlw .255 - movwf CNT1 +;; outer1 +;; movlw .255 +;; movwf CNT1 -inner - decfsz CNT1,f - goto inner +;; outer +;; movlw .20 +;; movwf CNT2 + +;; inner +;; decfsz CNT2,f +;; goto inner + +;; decfsz CNT1,f +;; goto outer - decfsz CNT0,f - goto outer +;; decfsz CNT0,f +;; goto outer1 - movlw b'00001000' - xorwf PORTB,f +;; movlw b'00001000' +;; xorwf PORTB,f goto main |