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

Output_bit , nothing

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



Joined: 30 Jan 2011
Posts: 16

View user's profile Send private message

Output_bit , nothing
PostPosted: Fri Mar 27, 2015 8:42 am     Reply with quote

Hi!
I use this code:
Code:

#include <12F683.h>
#device ADC=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES noPUT                      //Power Up Timer
#FUSES PROTECT                  //Code protected from reads
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled

#use delay(internal=4000000)

int16 i;
unsigned int16 data=0b0101010101010101;

void main()
{
   while(TRUE)
   {
      for(i=1;i<=16;++i)
      {
         output_bit(PIN_A5, shift_left(data,2,1));
         delay_ms(30); 
      }
   i=0;
   delay_ms(500);
 
   }//end while

}//end main

The output signal is continuous H level. What is wrong? (I'm going crazy ...) Confused
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Fri Mar 27, 2015 9:19 am     Reply with quote

After 480mSec, it will be.

You are shifting a 1 in every time, so after 16shifts, data will contain all 1's....

Code:

void main()
{
   unsigned int16 temp;
   while(TRUE)
   {
      temp=data;
      for(i=0;i<16;++i)
      {
         output_bit(PIN_A5, shift_left(&temp,2,1));
         delay_ms(30);
      }
      delay_ms(500);
   }//end while

}//end main


This way the value to shift is reloaded every loop.

Remember also 'shift_left' requires an _address_. Note the '&'.


Last edited by Ttelmah on Fri Mar 27, 2015 11:44 am; edited 1 time in total
Jhonny



Joined: 30 Jan 2011
Posts: 16

View user's profile Send private message

PostPosted: Fri Mar 27, 2015 10:13 am     Reply with quote

Okay, I begin to understand. Thank you very much, it seems to me that we have to work well. Embarassed
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