Converting some "C" to C18 for pic - newbie questions

Guys, some (probably very simple) questions!

I'm learning C18 on an 18F series pic. I'm converting some code for the SHT11 RH & temperature sensor I found on an old forum post and have a few questions.

1) The number types are different to those used in C18. Some of these are below, am I correct in guessing that BYTE ==> unsigned char, WORD ==> unsigned int ,DWORD ==> double,

BYTE k ; WORD tmp ; DWORD SHTTimer ;

2) There is also the line shown below. Can someone give me an idea of what this does, my initial thougth was some inline assembly code but......

asm(" ") ;

Thank you.

Reply to
Dennis
Loading thread data ...

I'd guess DWORD => "unsigned long", i.e. unsigned 32-bit integer. At least, that's what DWORD means on Windows, which is where the term seems to originate.

asm() generates inline assembler. An empty asm() directive is probably used to "provoke" specific behaviour from the compiler, but it's anyone's guess as to exactly what behaviour.

Reply to
Nobody

Depending on compiler it might be used to break flow control tracking to force some specific compiler behavior. In our compilers it would probably break register tracking forcing registers to reload and would likely change the way control and data flow is handled in the application.

Regards,

w..

-- Walter Banks Byte Craft Limited

formatting link

--- news://freenews.netfront.net/ - complaints: snipped-for-privacy@netfront.net ---

Reply to
Walter Banks

There is a include file that defines these. There are a bunch of struct and unions. Basically BYTE is a unsigned char, WORD is unsigned int and DWORD is unsigned long. If you look at the data types in the manual you will see that int is 16 bits, long is 32 bits. There are also definitions (plural) for POINTER. You can have a ROM pointer or a RAM pointer. On the 18F it is perfectly legal to have a destination pointer be a ROM pointer. You will write to the flash. Be careful and choose the proper strxxx() and memxxx() functions. There are different versions based on the source and destination (ram or flash).

Also make sure your library memory model matches your program compiled object model. IIRC the default library model is large memory model.

This will disable most of the compiler optimization for the current function. Not sure why someone would do this. Any asm() construct will do this. asm is normally used for assembly inlining. Look at NOP() and CLRWDT() macros in the processor include file.

--
Joe Chisolm
Marble Falls, Tx.
Reply to
Joe Chisolm

Thank you, I'll make the changes!

Reply to
Dennis

Thanks for the advice Joe.

Reply to
Dennis

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.