AnsweredAssumed Answered

Init code

Question asked by andreahmed on Oct 27, 2016
Latest reply on Nov 3, 2016 by Jithul_Janardhanan

Hi,

I'm trying to init code the blackfin 533, but the software does not boot up

here is the code


#include <sys/platform.h>
#include <sys/anomaly_macros_rtl.h>


#define PLL_msel 24
#define PLL_d 0x0
#define PLL_count 0x200
#define PLL_bypass 0x0
#define PLL_csel 0
#define PLL_ssel 6

#define ASYNC_SETUP 2
#define ASYNC_ACCESS 3
#define ASYNC_HOLD 1

#define SPI_setting 8

//define spi_output

.section program;
.global _main;

_main:   
    //*******Pre-Init Section******************************************
    [--SP] = ASTAT;     // The Stack Pointer, SP, is set to the end of
    [--SP] = RETS;      // scratchpad memory (0xFFB00FFC)
    [--SP] = (r7:1);    // by the On-Chip Boot Rom
    [--SP] = (p5:0);
    [--SP] = I0; [--SP] = I1; [--SP] = I2; [--SP] = I3;
    [--SP] = B0; [--SP] = B1; [--SP] = B2; [--SP] = B3;
    [--SP] = M0;[--SP] = M1;[--SP] = M2;[--SP] = M3;
    [--SP] = L0; [--SP] = L1; [--SP] = L2; [--SP] = L3;   
    //*****************************************************************
     
   
    //*******Initialize Flags************
   
    //Set PF as input
 P2.L = FIO_DIR & 0xffff;
 P2.H = FIO_DIR >> 16;
 R0 = W[P2](Z);
 BITSET(R0,14);     //Set PF14 as output: LED (BUZZER_ON)
 BITSET(R0,2);     //Set PF2  as output: EEPROM CS
 BITCLR(R0,1);     //Set PF1 as input (SPI_MAGN_A_CS)
 BITCLR(R0,7);     //Set PF7 as input (SPI_MAGN_B_CS)
 W[P2] = R0;
   
    //Set Active High Polarity
    P2.H = FIO_POLAR >> 16;
    P2.L = FIO_POLAR & 0xFFFF;
 R0 = W[P2](Z);
 BITCLR(R0,1);     //Set active high polarity for PF1
 BITCLR(R0,7);     //Set active high polarity for PF7
 W[P2] = R0;

    //Enable PF
 P2.H = FIO_INEN >> 16;
 P2.L = FIO_INEN & 0xFFFF;
 R0 = W[P2](Z);
 BITSET(R0,1);     //Enable PF1
 BITSET(R0,7);     //Enable PF7
 W[P2] = R0;
 
 // Set PF14 pin high
 P2.L = FIO_FLAG_D & 0xFFFF;
 P2.H = FIO_FLAG_D >> 16;
 R0 = W[P2](Z);
 BITSET(R0,14);     
 W[P2] = R0;    

 // enable watchdog 
 P0.H = WDOG_CNT >> 16;
 P0.L = WDOG_CNT & 0xFFFF;  
 R1.H = 0x000F;
 R1.L = 0x0000; 
 [P0] = R1;
 
 P1.H = WDOG_CTL >> 16;
 P1.L = WDOG_CTL & 0xFFFF;    
 R1 = 0;
 [P1] = R1;

 
 // load signature 
 P2.L = 0xFF901D80 & 0xFFFF;
 P2.H = 0xFF901D80 >> 16;
 
 R2 = [P2];
 
 R3.H = 0x6789;
 R3.L = 0xABCD;
 
 // check signature 
 cc = R3 == R2; 
 if cc jump check_true;
 
 // check false -> jump to BOOTLOADER
 R0.H = 0x2000;  // set start address
    R0.L = 0x1000; 
    jump post_init;
 
    // check true  -> jump to API     
 check_true:
  // Set PF14 pin low
 P1.L = FIO_FLAG_D & 0xFFFF;
 P1.H = FIO_FLAG_D >> 16;
 R0 = W[P1](Z);
 BITCLR(R0,14);     
 W[P1] = R0;  
 
 R1 = 0;
 [P2] = R1;  // clear signature !!
 R0.H = 0x2001;  // set start address
    R0.L = 0x0038;   
   
  
    post_init:
   
    //*******Post-Init Section********************************************
     
    L3 = [SP++]; L2 = [SP++]; L1 = [SP++]; L0 = [SP++];
    M3 = [SP++]; M2 = [SP++]; M1 = [SP++]; M0 = [SP++];
    B3 = [SP++]; B2 = [SP++]; B1 = [SP++]; B0 = [SP++];
    I3 = [SP++]; I2 = [SP++]; I1 = [SP++]; I0 = [SP++];
    (p5:0) = [SP++];
    (r7:1) = [SP++];       
    RETS = [SP++];
    ASTAT = [SP++];
    //********************************************************************
      
    
    RTS;
   
   

_main.END: 

Outcomes