I would use uint16_t instead of unsigned int. int16_t instead of int. Cast to (uint16_t) I never know what an int size is :-) Your operations might result in numbers greater than 16 bits; must make sure you deal with that. Cat > To: AVR-Chat@yahoogroups.com > From: djantoxa@rambler.ru > Date: Sat, 3 Sep 2011 01:10:58 +0300 > Subject: [AVR-Chat] Calculate signed and unsigned > > Hello! > > I using AtMega32A, AVRStudio 4.18SP3 and WinAVR 2011. > > unsigned int param1; > signed int param2; ( > unsigned int param3; > > OCR1B = (unsigned int)(param1 - param2); > OCR1A = (unsigned int)(param1 - param2 - param3); > > I do not get the correct result. How to calculate signed and unsigned variables? > > -- > Best regards, > Roman Antoshchenkov > > Kharkiv > Ukraine [Non-text portions of this message have been removed]
Message
RE: [AVR-Chat] Calculate signed and unsigned
2011-09-02 by Cat C
Attachments
- No local attachments were found for this message.