Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

HI-TECH C and __delay_ms()

Status
Not open for further replies.

trennonix

New Member
Hello,

I'm trynig the __delay_ms() function in hi-tech c lite edition

but i always get a warning about "implicit signed to unsigned conversion"

so the program runs as if the delay function was never written



this is the code:



#include <htc.h>

int _XTAL_FREQ=4000000;

unsigned long time=200;



void

main(void)

{

TRISB=0;

while (1){

RB0=1;

__delay_ms(time);

RB0=0;

__delay_ms(time);

}

}





tried to add the numbers directly into the function without declaring a variable, but i still got the same error

tried "(unsigned long)value" same thing :S



Any ideas? thanks a lot



btw i'm using the latest compiler (downloaded 3 days ago) for 10\12\16 family lite edition

running in Hi-Tide IDE also latest version
 

BeeBop

Active Member
Hello,

I'm trynig the __delay_ms() function in hi-tech c lite edition

but i always get a warning about "implicit signed to unsigned conversion"

so the program runs as if the delay function was never written



this is the code:



#include <htc.h>

int _XTAL_FREQ=4000000;

unsigned long time=200;



void

main(void)

{

TRISB=0;

while (1){

RB0=1;

__delay_ms(time);

RB0=0;

__delay_ms(time);

}

}





tried to add the numbers directly into the function without declaring a variable, but i still got the same error

tried "(unsigned long)value" same thing :S



Any ideas? thanks a lot



btw i'm using the latest compiler (downloaded 3 days ago) for 10\12\16 family lite edition

running in Hi-Tide IDE also latest version


I don't use HiTech, but I don't think __delay_ms(argument) wants an unsigned long as an argument. On most platforms a long is 32 bits (0 to 4294967296) It could be looking for an int or a char (0 to 255)
You should be able to do:

unsigned char time=200; (or char time = 200; or int time = 200; check your documents and help files to find out what the delay function wants as an argument)

__delay_ms(time);
 

trennonix

New Member
i'm thinking of taking the hard road (that is assembly); i know a bit of assembly so this might be the chance for me to work on my skills ;)
 

BeeBop

Active Member
I tried char and int, and i even tried putting the value directly in, my values were smaller than 255 :confused:
Without seeing the function, or information about it I can be of no help. You haven't even given a good indication of exactly what your error is, or what the header file you have included is...
 

trennonix

New Member
I get a warning :"implicit signed to unsigned conversion"
as for the header file, it is provided with the compiler and holds all the necessary declarations and functions (such as delay)
the documentation gives no help as i practically copy-pasted their code

I tried to write my own delay function, but in high level language things tend to get very imprecise (i'm trying to make 2 pics communicate together using a certain protocol)
and i find mixing asm with C very confusing since i have no idea which registers are taken and how to enter the variables from C to asm code (plus i don't want to bother looking at the dissassembly of it; looks messy)

Anyways thanks for your help, i'm writing to the support team of Hi-Tech c but they take one whole day to answer every question
my last answer was: "send me your source code"
so this my second day gone waiting for an answer :mad:

i think going assembly is for the best
 

trennonix

New Member
Thanks alot, I downloaded and took a quick look at it.
I'm going to stick with assembly for now since my project isn't very big.

If I run into some unsolvable problems (for me) i'll give SourceBoost a good try.
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top