I have a good quastion, why is my math function not working, the code is don below.
Code: Select all
unsigned int myADC;
unsigned short myPWM;
unsigned int SekvensPointer;
unsigned int RampeUpTime;
unsigned int RampeDownTime;
unsigned int MaxValue;
unsigned int MinValue;
void Bootup() {
CMCON0 = 0b00000111; //Deactivate the comparator modules
ADCON1 = 0x80; // Configure analog inputs and Vref
ANSEL = 0b00001111; //RA0 RA1 RA2 RA4 are anlog input
TRISA = 0b00011111; //
TRISC = 0b00001000; // Output only RC3 input
Pwm1_Init(5000); // Initialize PWM module at RC5
Pwm1_Start(); // Start PWM
}
void main() {
bootup();
SekvensPointer=1;
myPWM=0;
while (1) {
RampeUpTime = ADC_Read(0);
RampeDownTime = ADC_Read(3);
MaxValue = ADC_Read(1);
MinValue = ADC_Read(2);
RampeUpTime=RampeUpTime*15;
RampeDownTime=RampeDownTime*15;
MaxValue = RampeUpTime/4;
MinValue = MinValue/4;
if(PORTC.F3==0){
while(myPWM < MaxValue){
vdelay_ms(RampeUpTime);
myPWM= myPWM++;
PWM1_Set_Duty(myPWM);
}
}
if(PORTC.F3==1) {
while(myPWM > MinValue){
vdelay_ms(RampeDownTime);
myPWM= myPWM--;
PWM1_Set_Duty(myPWM);
}
}
}
}
but when i run this code withe normal nubers it is working.
So here is my qustions how does i convert a INT to Short, and How does i convert Float to Short???
and have i done some stupid code??
It is a PIC16f684