佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 2400|回复: 1

要如何使用mbi 5039(constant current sink driver with error detection)?

[复制链接]
发表于 9-9-2009 12:05 PM | 显示全部楼层 |阅读模式
我现在在研究着mbi 5039(constant current sink driver with error detection), 我知道mbi 5039 有open circuit detection, 可是我试了很久都无法收到 sdo 脚发送出来的data。各位有玩过类似ic 的朋友们, 请大家给于宝贵的意见。这是我跟着timing diagram 写的程序,请各位过目。有任何错的地方,请多多指教。

timing diagram:


source code:
#include <16F887.h>
#fuses INTRC
#USE STANDARD_IO (C)
#use delay (clock=4000000)


#define le     PIN_E2
#define clk    PIN_E1
#define sdi    PIN_E0
#define oe     PIN_C0
#define sdo    PIN_C1

int8 outputSignal1[4]={0xff,0xff};
int16 error_data[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
int16 total_error=0;
int1 led_state=0;

int8 period=0;

#INT_TIMER1
void TIMER1_isr(){

   if(period<1){
      period++;
   }else{
      if(led_state==0){
         led_state=1;
      }else if(led_state==1){
         led_state=0;
      }
      period=0;
   }
}

void show_digit(){
   unsigned int digit_no,svn_seg_ctr;
   output_low(clk);
   output_low(oe);
   output_low(le);
  
   
   for(digit_no=0;digit_no<2;digit_no++){
      for(svn_seg_ctr=0;svn_seg_ctr<8;svn_seg_ctr++){
      
      
         if(input(sdo)==true){
            error_data[svn_seg_ctr+digit_no*8]=1;   
            error_data[svn_seg_ctr+digit_no*8]=error_data[svn_seg_ctr+digit_no*8]<<(svn_seg_ctr+digit_no*8);
         }else{
            error_data[svn_seg_ctr+digit_no*8]=0;  
            error_data[svn_seg_ctr+digit_no*8]=error_data[svn_seg_ctr+digit_no*8]<<(svn_seg_ctr+digit_no*8);
         }
   
         output_bit(sdi, shift_left(&outputSignal1[digit_no], 1, 0));
         output_high(clk);
         delay_ms(4);
         output_low(clk);
         
      }
      total_error=error_data[0]|error_data[1]|error_data[2]|error_data[3]|error_data[4]
      |error_data[5]|error_data[6]|error_data[7]|error_data[8]|error_data[9]|error_data[10]
      |error_data[11]|error_data[12]|error_data[13]|error_data[14]|error_data[15];
   }  
   outputSignal1[0]=0xff;
   outputSignal1[1]=0xff;
   output_high(le);
   delay_us(4);
}

void get_error(){  
   output_low(clk);
   output_high(oe);
   delay_us(4);
   output_low(le);
   delay_us(10);
   output_high(le);
   delay_us(4);
   output_low(oe);   
}

void main (void){
   setup_oscillator( OSC_4MHZ );
   setup_timer_1( T1_INTERNAL | T1_DIV_BY_8 );
   enable_interrupts(GLOBAL);
   enable_interrupts( INT_TIMER1 );  
   output_high(PIN_C2);

   while(true){  
      if(total_error>0xf0f0){
         output_high(PIN_C2);
      }else{
         output_low(PIN_C2);
      }
      if(led_state==1){
         show_digit();
      }else{
         get_error();
      }
   }  
}
回复

使用道具 举报


ADVERTISEMENT

发表于 12-9-2009 08:24 PM | 显示全部楼层
原帖由 xiao1987 于 9-9-2009 12:05 PM 发表
我现在在研究着mbi 5039(constant current sink driver with error detection), 我知道mbi 5039 有open circuit detection, 可是我试了很久都无法收到 sdo 脚发送出来的data。各位有玩过类似ic 的朋友们, 请大家 ...

我用过的是没有Error detection 的。
你的mbi 5039 是哪里买的? 我也想买几颗来玩玩。

你的问题, 可能是OE, LE 控制到不好, 从这两个下功夫。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 6-2-2025 01:11 PM , Processed in 0.091901 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表