示例#1
0
void main()
{
	//enum data_source ABC;
	//ABC=PRBS7;
	tChar temp;
	lcd_init();
	display("Initializing...");
	enable_spi(0);
	dac_set(0);
	chip_init_CCFFE();
	pll_init();
	clearscr();
    enable_serial();
    display("Set Jumpers and ping");
    temp = receive_serial();
    clearscr();

	display("Offset trim DUT1");
	sel_source(OFFSET_CAL);
	msDelay(1);
	LF_SELECT = 0;
	CHIP_RESET = 0;
//	LF_SELECT=1;
	while(1);
//	{
//		LF_SELECT=1;
//		msDelay(10000);
//		LF_SELECT=0;
//		msDelay(10000);
//	}
}
void set_current_milliamps(uint32_t value) {
  setCurrentMilliamps = value;
#ifdef DAC_ENABLE
  dac_set(setMilliampsToDac(setCurrentMilliamps));
#endif
#ifdef DISP6800_ENABLE
  process_poll(&gfx_update_process);
#endif
}
示例#3
0
文件: dac.c 项目: forbelief/KL25EM
//============================================================================
//函数名称:dac_init
//函数返回:无
//参数说明:ModelNumber:通道号0、1。                         
//         RefVoltage:参考电压选择。0=1.2V,1=3.3V。
//功能概要:初始化DAC模块设定。
//============================================================================
void dac_init(uint8_t RefVoltage)
{
    uint8_t VreRF = DAC_SEL_VREFO;
    if(RefVoltage == 1)
    {
        VreRF =  DAC_SEL_VDDA;                 //3.3V 
    }
    
    //SIM_SCGC2 |= SIM_SCGC2_DAC0_MASK ;      //使能DAC 0
      SIM_SCGC6 |=SIM_SCGC6_DAC0_MASK;        //使能DAC0时钟
      dac_set(DAC0_BASE_PTR,VreRF);
}
示例#4
0
文件: main.c 项目: texane/pload
void pit1_isr(void)
{
  if (--pload_tick_count)
  {
    /* continue current step */

    if (pload_msg.u.steps.op[pload_step_index] == PLOAD_STEP_OP_RAMP)
    {
      pload_current += pload_msg.u.steps.arg0[pload_step_index];
      dac_set(ma_to_dac((uint32_t)pload_current));

#if 0 /* DEBUG */
      SERIAL_WRITE_STRING("dac_set:");
      serial_write(uint32_to_string((uint32_t)pload_current), 8);
      SERIAL_WRITE_STRING("\r\n");
#endif /* DEBUG */
    }

    goto on_done;
  }

  if ((++pload_step_index) == (uint32_t)pload_msg.u.steps.count)
  {
#if 0 /* DEBUG */
    SERIAL_WRITE_STRING("stopping\r\n");
#endif /* DEBUG */

    pit_stop(1);
    goto on_done;
  }

  /* current step done, load next state */

  switch (pload_msg.u.steps.op[pload_step_index])
  {
  case PLOAD_STEP_OP_CONST:
    {
    const_case:
      pload_current = (int32_t)pload_msg.u.steps.arg0[pload_step_index];
      dac_set(ma_to_dac((uint32_t)pload_current));

#if 0 /* DEBUG */
      SERIAL_WRITE_STRING("dac_set:");
      serial_write(uint32_to_string((uint32_t)pload_current), 8);
      SERIAL_WRITE_STRING("\r\n");
#endif /* DEBUG */

      pload_tick_count = (uint32_t)pload_msg.u.steps.arg1[pload_step_index];
      break ;
    }

  case PLOAD_STEP_OP_RAMP:
    {
      pload_current += (int32_t)pload_msg.u.steps.arg0[pload_step_index];
      dac_set(ma_to_dac((uint32_t)pload_current));

#if 0 /* DEBUG */
      SERIAL_WRITE_STRING("dac_set:");
      serial_write(uint32_to_string((uint32_t)pload_current), 8);
      SERIAL_WRITE_STRING("\r\n");
#endif /* DEBUG */

      pload_tick_count = (uint32_t)pload_msg.u.steps.arg1[pload_step_index];
      break ;
    }

  case PLOAD_STEP_OP_WAIT:
    {
      pload_tick_count = (uint32_t)pload_msg.u.steps.arg1[pload_step_index];
      break ;
    }

  case PLOAD_STEP_OP_REPEAT:
    {
      const int32_t repeat_count = pload_msg.u.steps.arg0[pload_step_index];

      if ((++pload_repeat_index) == (uint32_t)repeat_count)
      {
#if 0 /* DEBUG */
	SERIAL_WRITE_STRING("stopping\r\n");
#endif /* DEBUG */

	pit_stop(1);
	goto on_done;
      }

      if (repeat_count == -1)
      {
	pload_repeat_index = 0;
      }

      /* next step */
      pload_step_index = 0;
      goto const_case;
      break ;
    }

  default: break ;
  }

 on_done:
  pit_clear_int(1);
}
示例#5
0
文件: main.c 项目: texane/pload
int main(void)
{
  uint32_t msize;
  uint32_t rsize;

#ifdef DAC_USE_VREF
  vref_setup();
#endif /* DAC_USE_VREF */

  dac_setup();
  dac_enable();

  serial_setup();

  msize = 0;

  while (1)
  {
    rsize = serial_get_rsize();
    if (rsize > (sizeof(pload_msg) - msize)) rsize = sizeof(pload_msg) - msize;
    if (rsize == 0) continue ;

    /* stop the generator if active */

    if (pload_flags & PLOAD_FLAG_IS_STARTED)
    {
#if 0 /* DEBUG */
      SERIAL_WRITE_STRING("stopping\r\n");
#endif /* DEBUG */

      pload_flags &= ~PLOAD_FLAG_IS_STARTED;
      pit_stop(1);
    }

    serial_read((uint8_t*)&pload_msg + msize, rsize);
    msize += rsize;
    if (msize != sizeof(pload_msg)) continue ;

    /* new message */
    msize = 0;

    if (pload_msg.op != PLOAD_MSG_OP_SET_STEPS) continue ;

    /* start the generator */

    if ((pload_flags & PLOAD_FLAG_IS_STARTED) == 0)
    {
#if 0 /* DEBUG */
      SERIAL_WRITE_STRING("starting\r\n");
#endif /* DEBUG */

      pload_step_index = 0;
      pload_tick_count = (uint32_t)pload_msg.u.steps.arg1[0];
      pload_repeat_index = 0;
      pload_current = (int32_t)pload_msg.u.steps.arg0[0];

      dac_set(ma_to_dac((uint32_t)pload_current));

#if 0 /* DEBUG */
      SERIAL_WRITE_STRING("dac_set:");
      serial_write(uint32_to_string((uint32_t)pload_current), 8);
      SERIAL_WRITE_STRING("\r\n");
#endif /* DEBUG */

      pload_flags |= PLOAD_FLAG_IS_STARTED;
      pit_start(1, F_BUS / PLOAD_CLOCK_FREQ);
    }
  }

  return 0;
}
void main()
{
	int i=10,j,k,N=24;
	tInt bias,scale;
	tLong frequency;
	tChar temp;
//	__bit test_resultA;

	FLG_CPL=0;
	lcd_init();
	display("Initializing...");
	enable_spi(0);
	dac_set(0);
	chip_init_CCFFE();
	pll_init();
	clearscr();
	enable_serial();
	display("Set Jumpers and ping");
	temp = receive_serial();
	clearscr();
	display("     CCFFE");
	line2();
	display("Throughput test");
	
	msDelay(1000);
	enable_serial();
	load_test_data();
	clearscr();
	display("Setting up test");
	line2();
	display("With 7 bit PRBS");
	scale = 2650/N;
	
	for(i=N;i>0;i--)
	{
		for(j=0;j<20;j++)
		{
			chip_init_CCFFE();
			sel_source(RING);
			bias=scale*i;
			dac_set(bias);
			msDelay(1000);			
			for(k=j;k>=0;k--)
			{
				tick_RX_RC_CKIN();
				msDelay(1);
			}
        	frequency = fmeasure();
        	clearscr();
        	display("f(");
			display_int(i);
			display(",");
        	display_int(j);
        	display(")=");
        	display_freq(frequency);
			write_test_data_CCFFE();
			LF_SELECT = 0;
			msDelay(1);
			LF_SELECT = 1;
			read_results_CCFFE();
			test_result = cross_correlation();//source_data);
			if(test_result)
			{
				FLG_CPL=1;
                send_byte(fm_byte[0]);
                send_byte(fm_byte[1]);
                send_byte(fm_byte[2]);
                send_int(i);
                send_byte(',');
                send_int(j);
			}
		}
	}
	

	
	clearscr();
	display("Throughput test");
	line2();
	if(FLG_CPL)
	display("SUCCESS");
	else
	display("Failed");
	while(1);
}
void dc_electronic_load_setup() {
  setCurrentMilliamps = 0;
  readCurrentMilliamps = 0;
  readMilliVolts = 0;
  setRateIndex = 0;
  readCurrentMilliampsDisplay = DISPLAY_MILLI;
  gfxState = GFX_STATE_MEASURE;

  dma_ring_buffer_init(&g_debugUsartDmaInputRingBuffer, DEBUG_USART_RX_DMA_CH, g_debugUsartRxBuffer, DEBUG_USART_RX_BUFFER_SIZE);

  debug_setup();
  debug_write_line("?BEGIN setup");

  process_init();
  process_start(&etimer_process, NULL);

  process_start(&debug_process, NULL);
#ifdef DISP6800_ENABLE
  process_start(&gfx_update_process, NULL);
  process_poll(&gfx_update_process);
#endif

  spi_setup();

#ifdef DISP6800_ENABLE
  disp6800_setup();
  gfx_setup();
#endif

#ifdef ENCODER_ENABLE
  encoder_setup();
#endif

#ifdef FLASH_ENABLE
  flashsst25_setup();
#endif

#ifdef MAC_ENABLE
  mac25aa02e48_setup();
  mac25aa02e48_read_eui48();
#endif

#ifdef ADC_ENABLE
  adc_setup();
#endif

#ifdef DAC_ENABLE
  dac_setup();
  dac_set(0);
#endif

#ifdef NETWORK_ENABLE
  network_setup(EUI48);
#endif

#ifdef FAN_ENABLE
  fan_setup();
#endif

#ifdef BUTTONS_ENABLE
  buttons_setup();
#endif

  time_setup();
  recorder_setup();

  debug_write_line("?END setup");
}