TheLegace

ExpandedMode.c

Apr 11th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1.  
  2. extern volatile char DATAH, DATAL;
  3.  
  4. void main(void){
  5.     /* Set bus clock to 24 MHz */
  6.     /* Setup Dbug12 does*/
  7.     asm(" sei;");
  8.     CLKSEL &= ~0x80;
  9.     PLLCTL |= 0x40;
  10.     SYNR = 0x05;
  11.     REFDV = 0x01;
  12.     while ((CRGFLG & 0x08) == 0) ;
  13.     CLKSEL |= 0x80;
  14.    
  15.     MODE = 0xA8 /* Normal Expanded Narrow mode, internal visibility */
  16.     PEAR = 0x2C /* PIPOE, enable E-clock, LSTRB, R/W */
  17.     MISC = 0x03 /* No clock stretching, turn of EEPROM, DBug12 @ 8000-FFFF*/
  18.     EBICTL = 0x01;  /* Use E-clock to control external bus */
  19.     EnableInterrupts;
  20.     for(;;)
  21. }
  22.  
  23. void write(char addr, char dataH, char dataL){
  24.    
  25.     PORTB = addr;
  26.     PORTA = dataL; /*Only take lower paramter and pass*/
  27.     PORTE_BIT2 = 0; /* R/W assert low for write*/
  28.    
  29. }
  30.  
  31. void read(char addr){
  32.     PORTB = addr;
  33.     PORTE_BIT2 = 1 /* R/W assert high for read*/
  34.     DATAL = PORTA;
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment