mohammad3d
Joined: 28 Mar 2009 Posts: 17
|
Toshiba TCD1304AP linear CCD driver ... |
Posted: Mon Jul 29, 2019 1:52 am |
|
|
Hi every one,
I try to drive a TCD1304AP linear ccd with PIC24Hj12gp201 Micro and share this driver with all of you,
This driver work about 60 Fps with minimum part and connection.
I connect TCD1304AP driectly to PIC and discard 74hc04 invert buffer driver that use in TCD1304AP PDF circuit. 2sa1015 transistor still remain.
try this and enjoy,
Code: |
//compiler ver 4.140
#include <24hj12gp201.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOJTAG //JTAG disabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOIOL1WAY //Allows multiple reconfigurations of peripheral pins
#FUSES NOWINDIS //Watch Dog Timer in Window mode
#FUSES WPRES128 //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16 //Watch Dog Timer PostScalar 1:32768
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES FRC //Internal Fast RC Oscillator
#FUSES NOCKSFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO //OSC2 is general purpose output
#FUSES NOPR //Pimary oscillaotr disabled
#use delay(clock=80M,internal)//internal oscillaotr with PLL at 80Mhz (40MIPS)
#use standard_io(all)
#PIN_SELECT OC1=PIN_B4 //remappable peripheral pin assigned to Output Compare 1
// PIC TCD1304AP
//B7(pin 10)---->ICG(pin3)
//B4( pin 8)---> Mc (pin4) 1Mhz PWM
//B9(pin 12)---> SH (pin5)
#define ICG PIN_B7
#define SH PIN_B9
int16 shutter=1;
void main()
{
//setup PWM1 to 1MHZ 50%
setup_timer2(TMR_INTERNAL | TMR_DIV_BY_1, 39);
setup_compare(1, COMPARE_PWM | COMPARE_TIMER2);
set_pwm_duty(1, 19);
//initial state of control pin
output_bit( SH, 0);
output_bit( ICG, 1);
for(;;)//main loop
{
//sync to rise edge of master clock
while (input_state(PIN_B4)==1);//check logical level of master clock pin B4
while (input_state(PIN_B4)==0);
while (input_state(PIN_B4)==1);
delay_cycles(20 );
output_bit( ICG, 0);
delay_cycles(20);
output_bit( SH, 1);
delay_us(5);
while (input_state(PIN_B4)==1);//check logical level of master clock pin B4
output_bit( SH, 0);
delay_us(3);
while (input_state(PIN_B4)==0);//check logical level of master clock pin B4
while (input_state(PIN_B4)==1);
while (input_state(PIN_B4)==0);
delay_cycles( 1 );
output_bit( ICG, 1);
delay_us(5);
output_bit( SH, 1);
delay_us(5);
//generate electric shutter
for(shutter=1;shutter<800;shutter++)
{
output_bit( SH, 0);
delay_us(15);
output_bit( SH, 1);
delay_us(5);
}
}//main loop
}//main
|
|
|