CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Gyro data Acquisition in Timer interruption

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Monk666



Joined: 25 Oct 2008
Posts: 2

View user's profile Send private message

Gyro data Acquisition in Timer interruption
PostPosted: Wed Dec 10, 2008 11:22 am     Reply with quote

Gyro data Acquisition in Timer interrupt:
I try use the KamPutty's code for LIS3LV02DQ(Gyro) in interrupt for every 50ns.
When I use KamPutty's code
http://forum.sparkfun.com/viewtopic.php?p=18666)
alone it worked just fine.
But when I put those code in Timer interruption, it wouldn't work any
more, and the receiving data just stuck at the same number and never change.

Does anyone knowing what happened?
Code:

void main()
{
setup_spi(FALSE);

setup_timer_1 ( T1_INTERNAL | T1_DIV_BY_2 );

setup_ccp2 ( CCP_COMPARE_INT );  // configure CCP2 in COMPARE mode and ...
                                    // CCP2 Interrupt on compare match

enable_interrupts ( INT_CCP2 );

set_timer1(0);
CCP_2=ccp2_period;   // start the CCP2_ISR at 1 msec later

setup_adc_ports(AN0_TO_AN1|VSS_VDD);
setup_adc ( ADC_CLOCK_DIV_32 );  // 32 * T_osc = 1.6 us per bit at 20 MHz
set_adc_channel ( 0 );           // select RA0 as analog input channel

enable_interrupts ( GLOBAL   );
delay_us(100);
write_16bit_serial_data(0x20, 0b11000111); //原始設定是+-2G
write_16bit_serial_data(0x21, 0b00000001);
printf("Who Am I = %d\n\r", read_8bit_serial_data(0x0f));
delay_ms(1000);

while ( 1 )
   {
      while ( !kbhit() )            // press any key to get out
      {
         delay_ms ( 200 );          // wait 200 msec

        //printf("\r\n T= %lu.%04lu sec, AN0= %lu, yout=%f ", time_sec, time_tick, ad_data, yout );
         //printf("\r\n T= %lu.%04lu sec, AN0= %lu ", time_sec, time_tick, ad_data);
        //printf("\r\n Test variable for e_previous=%f", e_previous );
        //printf("\r\n Test variable for x_acc=%lu  y_acc=%lu  z_acc=%lu", X,Y,Z);
        //printf("\r\n Test variable for y_acc=%lu", y_acc);
        //printf("\r\n Test variable for max_duty=%lu", max_duty );
        //printf("\r\n Test variable for duty_set=%lu", duty_set );
         printf("\r\n Test =%lu", test);
        //printf("\n\n\r ",);

      };
    }
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group