2

My code will not compile because of this error in this function can anyone help

void SetDCPWM(unsigned int dutycycle) {

unsigned int local_dutycycle;
local_dutycycle = dutycycle;

CCPR1L = (dutycycle >>2);

CCP1CONbits.DC1B = local_dutycycle & 0x0003;

return; }

I am getting this error

Error   [255] C:\KEVIN-WORK\WORK\SM511602\SM511601 TEK572A Syspeo RS232 receiver.c; 352.18 not a member of the struct/union ""

Error   [182] C:\KEVIN-WORK\WORK\SM511602\SM511601 TEK572A Syspeo RS232 receiver.c; 352.44 illegal conversion between types
unsigned int -> volatile union S30
Lundin
  • 195,001
  • 40
  • 254
  • 396
Gooner1990
  • 35
  • 5
  • yes I included the error messages in the post. I have tried but cannot find a fix – Gooner1990 Oct 31 '14 at 12:34
  • DC1B is apparently not a member of CCP1CONbits. Make sure both of those exist and that you include the header file where they are declared. – Lundin Oct 31 '14 at 12:37
  • 1
    Since `CCPR1L` and `CCP1CONbits` look like macros, you can run your compiler to preprocess only. On GCC, this the `-E` option. – Blagovest Buyukliev Oct 31 '14 at 12:38
  • What compiler are you using? Is this MPLAB? – SurDin Oct 31 '14 at 12:38
  • 1
    this seems to be the problem line: CCP1CONbits.DC1B = local_dutycycle & 0x0003; it would have been very nice if you had added a comment indicating this is the problem line. What is the definition of CP1CONbits? – user3629249 Nov 01 '14 at 05:32
  • I guess that the CCP1CONbits.DC1B register is an 8 bits register (pic16f are 8 bits architecture). And you are trying to put 16 bits in it (0x0003 is a 16 bits field). That could be the origin of the 2nd error (352.44 illegal conversion between types). – cyrille Nov 01 '14 at 22:08

0 Answers0