diff options
-rw-r--r-- | multiplexer.c | 14 | ||||
-rw-r--r-- | multiplexer.h | 3 |
2 files changed, 16 insertions, 1 deletions
diff --git a/multiplexer.c b/multiplexer.c index 50da183..ab39e08 100644 --- a/multiplexer.c +++ b/multiplexer.c @@ -93,6 +93,7 @@ void *put_on_display(void *param) } for (column=0; column<8; column++) { GPIO_ALTER(column + line == 7) = 1<<SER_DAT_PIN; + wait_tpic_settle_time GPIO_CLR = 1<<SER_CLK_PIN; wait_tpic_settle_time GPIO_SET = 1<<SER_CLK_PIN; @@ -100,6 +101,7 @@ void *put_on_display(void *param) } for (column=39; column>=0; column--) { GPIO_ALTER(display_data -> buf[display_data -> is_buf][column] & (0x01 << line)) = 1<<SER_DAT_PIN; + wait_tpic_settle_time GPIO_CLR = 1<<SER_CLK_PIN; wait_tpic_settle_time GPIO_SET = 1<<SER_CLK_PIN; @@ -116,6 +118,18 @@ void *put_on_display(void *param) perror("clock_gettime failed"); break; } + // adjust tpic_settle_time_iterator + if ((tpic_settle_time_iterator > 0) && (stop_time.tv_sec - start_time.tv_sec + (stop_time.tv_nsec - start_time.tv_nsec) / 1000000000. > 0.0003)) { +// fprintf(stderr, "%d -> ", tpic_settle_time_iterator); + tpic_settle_time_iterator--; +// fprintf(stderr, "%d\n", tpic_settle_time_iterator); + } + else if ((tpic_settle_time_iterator < 200000) && (stop_time.tv_sec - start_time.tv_sec + (stop_time.tv_nsec - start_time.tv_nsec) / 1000000000. < 0.0001)) { +// fprintf(stderr, "%d -> ", tpic_settle_time_iterator); + tpic_settle_time_iterator++; + tpic_settle_time_iterator *= 2; +// fprintf(stderr, "%d\n", tpic_settle_time_iterator); + } // wait until start_time + 1ms int wait = (start_time.tv_sec - stop_time.tv_sec) * 1000000 + (start_time.tv_nsec - stop_time.tv_nsec) / 1000 + 1000; if (wait > 0) diff --git a/multiplexer.h b/multiplexer.h index 4f94f17..3fb1f87 100644 --- a/multiplexer.h +++ b/multiplexer.h @@ -49,7 +49,8 @@ static uint8_t gpioToPUDCLK [] = #define SCROLL_BUF_LEN 4096 -#define wait_tpic_settle_time for (int i=0; i<100; i++) { asm volatile("" : : "r" (i)); } +static int tpic_settle_time_iterator = 1000; +#define wait_tpic_settle_time for (int i=0; i<tpic_settle_time_iterator; i++) { asm volatile("" : : "r" (i)); } int mem_fd; void *gpio_map; |