|
|
View previous topic :: View next topic |
Author |
Message |
Jhonny
Joined: 30 Jan 2011 Posts: 16
|
Output_bit , nothing |
Posted: Fri Mar 27, 2015 8:42 am |
|
|
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 ...) |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Fri Mar 27, 2015 9:19 am |
|
|
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
|
|
Posted: Fri Mar 27, 2015 10:13 am |
|
|
Okay, I begin to understand. Thank you very much, it seems to me that we have to work well. |
|
|
|
|
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
|