avr_mdcart_sram_lite

changeset 6:ff8af8351282

works
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 12 Mar 2017 23:43:41 +0200
parents abb348704dec
children f14e14abe14c
files Makefile main.c
diffstat 2 files changed, 14 insertions(+), 14 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Sun Mar 12 04:27:43 2017 +0200
     1.2 +++ b/Makefile	Sun Mar 12 23:43:41 2017 +0200
     1.3 @@ -27,7 +27,7 @@
     1.4  
     1.5  .PHONY: fuses
     1.6  fuses:
     1.7 -	avrdude -c usbtiny -p $(mcu_dude) -U lfuse:w:0xf7:m -U hfuse:w:0x99:m -U efuse:w:0xff:m
     1.8 +	avrdude -c usbtiny -p $(mcu_dude) -U lfuse:w:0xf7:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m
     1.9  
    1.10  .PHONY: program
    1.11  program: $(hex)
     2.1 --- a/main.c	Sun Mar 12 04:27:43 2017 +0200
     2.2 +++ b/main.c	Sun Mar 12 23:43:41 2017 +0200
     2.3 @@ -64,7 +64,7 @@
     2.4  
     2.5  int main(void)
     2.6  {
     2.7 -	init_serial(38400);
     2.8 +	init_serial(115200);
     2.9  	run_mode();
    2.10  
    2.11  	sei();
    2.12 @@ -101,12 +101,12 @@
    2.13  
    2.14  	case 'p':
    2.15  		prog_mode();
    2.16 -		printf("OK programming mode\n");
    2.17 +		puts("OK programming mode");
    2.18  		break;
    2.19  
    2.20  	case 'b':
    2.21  		run_mode();
    2.22 -		printf("OK boot mode\n");
    2.23 +		puts("OK run mode");
    2.24  		break;
    2.25  
    2.26  	case 'a':
    2.27 @@ -116,26 +116,26 @@
    2.28  
    2.29  	case 'w':
    2.30  		if(running) {
    2.31 -			printf("ERR running\n");
    2.32 +			puts("ERR running");
    2.33  			break;
    2.34  		}
    2.35  		if(addr >= MEM_SIZE) {
    2.36 -			printf("ERR overflow\n");
    2.37 +			puts("ERR overflow");
    2.38  			break;
    2.39  		}
    2.40  
    2.41  		data = strtol(input + 1, &endp, 0);
    2.42  		sram_write(addr++, data);
    2.43 -		printf("OK %d\n", (int)data);
    2.44 +		puts("OK");
    2.45  		break;
    2.46  
    2.47  	case 'r':
    2.48  		if(running) {
    2.49 -			printf("ERR running\n");
    2.50 +			puts("ERR running");
    2.51  			break;
    2.52  		}
    2.53  		if(addr >= MEM_SIZE) {
    2.54 -			printf("ERR overflow\n");
    2.55 +			puts("ERR overflow");
    2.56  			break;
    2.57  		}
    2.58  
    2.59 @@ -144,7 +144,7 @@
    2.60  		break;
    2.61  
    2.62  	default:
    2.63 -		printf("ERR unknown command\n");
    2.64 +		puts("ERR unknown command");
    2.65  		break;
    2.66  	}
    2.67  }
    2.68 @@ -152,14 +152,15 @@
    2.69  void run_mode(void)
    2.70  {
    2.71  	/* tri-state everything and release the reset line */
    2.72 +	/* do not tri-state WE and keep it high */
    2.73  	DDRA = 0;
    2.74  	PORTA = 0;
    2.75  	DDRB = 0;
    2.76  	PORTB = 0;
    2.77  	DDRC = 0;
    2.78  	PORTC = 0;
    2.79 -	DDRD = RST_BIT;
    2.80 -	PORTD = RST_BIT;
    2.81 +	DDRD = RST_BIT | WE_BIT;
    2.82 +	PORTD = RST_BIT | WE_BIT;
    2.83  
    2.84  	running = 1;
    2.85  }
    2.86 @@ -167,7 +168,7 @@
    2.87  void prog_mode(void)
    2.88  {
    2.89  	/* hold the reset line and take control of the bus */
    2.90 -	PORTD = 0;
    2.91 +	PORTD = WE_BIT;	/* keep WE high to avoid writing random bytes */
    2.92  	DDRD = 0xff;
    2.93  	DDRA = 0xff;
    2.94  	DDRB = 0xff;
    2.95 @@ -192,7 +193,6 @@
    2.96  
    2.97  	/* pulse WE */
    2.98  	PORTD &= ~WE_BIT;
    2.99 -	_delay_us(0.1);
   2.100  	/* WE should be low for at least 9ns, which is way faster than we can toggle it anyway */
   2.101  	PORTD |= WE_BIT;
   2.102  }