Little problem with this code xc8

Thread Starter

be80be

Joined Jul 5, 2008
2,395
This still not right
Code:
void NeoBit (int Bit)  //It will not let me use just Bit
{
   if (bit == 1)
   {
       LATBbits.NeoPin = 1
         _delay(6)
         LATBbits.NeoPin = 0
   }
   else
   {
       LATBbits.NeoPin = 1
          _delay(3)
       LATBbits.NeoPin = 0
   }
}
Screenshot from 2018-01-27 13-06-06.png
/home/burt/code/ws8test/NeoCol.c:11: error: (195) expression syntax
/home/burt/code/ws8test/NeoCol.c:11: error: (194) ")" expected
/home/burt/code/ws8test/NeoCol.c:11: error: (249) probable missing "}" in previous block
/home/burt/code/ws8test/NeoCol.c:11: error: (285) no identifier in declaration
/home/burt/code/ws8test/NeoCol.c:11: error: (314) ";" expected
/home/burt/code/ws8test/NeoCol.c:17: error: (285) no identifier in declaration
/home/burt/code/ws8test/NeoCol.c:17: warning: (374) missing basic type; int assumed
/home/burt/code/ws8test/NeoCol.c:17: error: (314) ";" expected
/home/burt/code/ws8test/NeoCol.c:23: error: (285) no identifier in declaration
/home/burt/code/ws8test/NeoCol.c:23: warning: (374) missing basic type; int assumed
/home/burt/code/ws8test/NeoCol.c:23: error: (314) ";" expected
/home/burt/code/ws8test/NeoCol.c:51: error: (183) function or function pointer required
/home/burt/code/ws8test/NeoCol.c:51: error: (981) pointer required
/home/burt/code/ws8test/NeoCol.c:53: error: (183) function or function pointer required
/home/burt/code/ws8test/NeoCol.c:53: error: (981) pointer required
/home/burt/code/ws8test/NeoCol.c:55: error: (183) function or function pointer required
/home/burt/code/ws8test/NeoCol.c:55: error: (981) pointer required
/home/burt/code/ws8test/NeoCol.c:57: error: (255) not a member of the struct/union ""
/home/burt/code/ws8test/NeoCol.c:57: error: (183) function or function pointer required
/home/burt/code/ws8test/NeoCol.c:57: warning: (1385) variable "RB0" is deprecated (declared at /home/burt/code/ws8test/NeoCol.c:57)
/home/burt/code/ws8test/NeoCol.c:57: error: (981) pointer required
/home/burt/code/ws8test/NeoCol.c:57: error: (182) illegal conversion between types
int -> volatile union S107
/home/burt/code/ws8test/NeoCol.c:65: warning: (373) implicit signed to unsigned conversion
/home/burt/code/ws8test/NeoCol.c:66: warning: (373) implicit signed to unsigned conversion
/home/burt/code/ws8test/NeoCol.c:67: warning: (373) implicit signed to unsigned conversion
(908) exit status = 1
nbproject/Makefile-default.mk:106: recipe for target 'build/default/production/_ext/1693387515/NeoCol.p1' failed
make[2]: Leaving directory '/home/burt/code/ws8test'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory '/home/burt/code/ws8test'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

BUILD FAILED (exit value 2, total time: 492ms)
 
Last edited:

AlbertHall

Joined Jun 4, 2014
12,640
This version compiles - don't know whether it does what it is supposed to do.
C:
#include "NeoCol.h"
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <xc.h>

uint8_t NeoGreen [NeoNum];
uint8_t NeoBlue [NeoNum];
uint8_t NeoRed [NeoNum];

void NeoBit (bool  Bit);
bool bit_test(uint8_t Byte, signed char BitCount);

void NeoBit (bool  Bit)
{
   if (Bit == 1)
   {
       NeoPin = 1;
       _delay(6);
       NeoPin = 0;
   }
   else
   {
       NeoPin = 1;
       _delay(3);
       NeoPin = 0;
   }
}

void NeoInit (void)
{
   unsigned char NeoPixel;
   for (NeoPixel = 0; NeoPixel < NeoNum; NeoPixel++)
   {
      if (NeoPixel < 10)
         { NeoGreen[NeoPixel] = 0; NeoBlue[NeoPixel] = 0; NeoRed[NeoPixel] = 64; }
      else if ((NeoPixel >= 10) & (NeoPixel < 20))
         { NeoGreen[NeoPixel] = 0; NeoBlue[NeoPixel] = 64; NeoRed[NeoPixel] = 0; }
      else if ((NeoPixel >= 20) & (NeoPixel < 30))
         { NeoGreen[NeoPixel] = 0; NeoBlue[NeoPixel] = 64; NeoRed[NeoPixel] = 64; }
      else if ((NeoPixel >= 30) & (NeoPixel < 40))
         { NeoGreen[NeoPixel] = 64; NeoBlue[NeoPixel] = 0; NeoRed[NeoPixel] = 0; }
      else if ((NeoPixel >= 40) & (NeoPixel < 50))
         { NeoGreen[NeoPixel] = 64; NeoBlue[NeoPixel] = 0; NeoRed[NeoPixel] = 64; }
      else if ((NeoPixel >= 50) & (NeoPixel < NeoNum))
         { NeoGreen[NeoPixel] = 64; NeoBlue[NeoPixel] = 64; NeoRed[NeoPixel] = 0; } 
   }
}
void NeoDraw (void)
{
   unsigned char NeoPixel;
   signed char BitCount;
 
   for (NeoPixel = 0; NeoPixel < NeoNum; NeoPixel++)
   {
      for (BitCount = 7; BitCount >= 0; BitCount--) 
         NeoBit(bit_test(NeoGreen[NeoPixel], BitCount)); 
      for (BitCount = 7; BitCount >= 0; BitCount--)     
         NeoBit(bit_test(NeoRed[NeoPixel], BitCount));       
      for (BitCount = 7; BitCount >= 0; BitCount--) 
         NeoBit(bit_test(NeoBlue[NeoPixel], BitCount)); 
   }
   NeoPin =0;
}
void NeoRotate (void)
{
   unsigned uint8_t NeoPixel;
   for (NeoPixel = 0; NeoPixel < NeoNum - 1; NeoPixel++)
   {     
      NeoGreen[NeoPixel] = NeoGreen[NeoPixel + 1];
      NeoBlue[NeoPixel] = NeoBlue[NeoPixel + 1];
      NeoRed[NeoPixel] = NeoRed[NeoPixel + 1];
   }
   NeoGreen[NeoNum - 1] = NeoGreen[0];
   NeoBlue[NeoNum - 1] = NeoBlue[0];
   NeoRed[NeoNum - 1] = NeoRed[0];
}

bool bit_test(uint8_t Byte, signed char BitCount)
{
    return ((Byte >> BitCount) & 0x01);
}

void main()
{
   NeoInit ();
   while(1)
   { 
      NeoDraw ();
      NeoRotate ();
      __delay_ms (25);
   }
}
C:
// PIC18F2550 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1L
#pragma config PLLDIV = 1       // PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))
#pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2])
#pragma config USBDIV = 1       // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)

// CONFIG1H
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator (HS))
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)

// CONFIG2L
#pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOR = ON         // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config BORV = 3         // Brown-out Reset Voltage bits (Minimum setting 2.05V)
#pragma config VREGEN = OFF     // USB Voltage Regulator Enable bit (USB voltage regulator disabled)

// CONFIG2H
#pragma config WDT = ON         // Watchdog Timer Enable bit (WDT enabled)
#pragma config WDTPS = 128      // Watchdog Timer Postscale Select bits (1:128)

// CONFIG3H
#pragma config CCP2MX = ON      // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBADEN = ON      // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
#pragma config LPT1OSC = OFF    // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
#pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)

// CONFIG4L
#pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = OFF        // Single-Supply ICSP Enable bit (Single-Supply ICSP disabled)
#pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))

// CONFIG5L
#pragma config CP0 = OFF        // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
#pragma config CP1 = OFF        // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
#pragma config CP2 = OFF        // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
#pragma config CP3 = OFF        // Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)

// CONFIG5H
#pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
#pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)

// CONFIG6L
#pragma config WRT0 = OFF       // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
#pragma config WRT1 = OFF       // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
#pragma config WRT2 = OFF       // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
#pragma config WRT3 = OFF       // Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)

// CONFIG6H
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)

// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR2 = OFF      // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
#pragma config EBTR3 = OFF      // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)

// CONFIG7H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <pic18f2550.h>
#include <xc.h>
#define _XTAL_FREQ  40000000

#define NeoPin LATBbits.LATB0
#define NeoNum 4
#define ALL_OUT 0x00
#define ALL_IN  0xFF
 

nsaspook

Joined Aug 27, 2009
16,438
This still not right
Code:
void NeoBit (int Bit)  //It will not let me use just Bit
{
   if (bit == 1)
   {
       LATBbits.NeoPin = 1
         _delay(6)
         LATBbits.NeoPin = 0
   }
   else
   {
       LATBbits.NeoPin = 1
          _delay(3)
       LATBbits.NeoPin = 0
   }
}
View attachment 144506
/home/burt/code/ws8test/NeoCol.c:11: error: (195) expression syntax
/home/burt/code/ws8test/NeoCol.c:11: error: (194) ")" expected
/home/burt/code/ws8test/NeoCol.c:11: error: (249) probable missing "}" in previous block
/home/burt/code/ws8test/NeoCol.c:11: error: (285) no identifier in declaration
/home/burt/code/ws8test/NeoCol.c:11: error: (314) ";" expected
/home/burt/code/ws8test/NeoCol.c:17: error: (285) no identifier in declaration
/home/burt/code/ws8test/NeoCol.c:17: warning: (374) missing basic type; int assumed
/home/burt/code/ws8test/NeoCol.c:17: error: (314) ";" expected
/home/burt/code/ws8test/NeoCol.c:23: error: (285) no identifier in declaration
/home/burt/code/ws8test/NeoCol.c:23: warning: (374) missing basic type; int assumed
/home/burt/code/ws8test/NeoCol.c:23: error: (314) ";" expected
/home/burt/code/ws8test/NeoCol.c:51: error: (183) function or function pointer required
/home/burt/code/ws8test/NeoCol.c:51: error: (981) pointer required
/home/burt/code/ws8test/NeoCol.c:53: error: (183) function or function pointer required
/home/burt/code/ws8test/NeoCol.c:53: error: (981) pointer required
/home/burt/code/ws8test/NeoCol.c:55: error: (183) function or function pointer required
/home/burt/code/ws8test/NeoCol.c:55: error: (981) pointer required
/home/burt/code/ws8test/NeoCol.c:57: error: (255) not a member of the struct/union ""
/home/burt/code/ws8test/NeoCol.c:57: error: (183) function or function pointer required
/home/burt/code/ws8test/NeoCol.c:57: warning: (1385) variable "RB0" is deprecated (declared at /home/burt/code/ws8test/NeoCol.c:57)
/home/burt/code/ws8test/NeoCol.c:57: error: (981) pointer required
/home/burt/code/ws8test/NeoCol.c:57: error: (182) illegal conversion between types
int -> volatile union S107
/home/burt/code/ws8test/NeoCol.c:65: warning: (373) implicit signed to unsigned conversion
/home/burt/code/ws8test/NeoCol.c:66: warning: (373) implicit signed to unsigned conversion
/home/burt/code/ws8test/NeoCol.c:67: warning: (373) implicit signed to unsigned conversion
(908) exit status = 1
nbproject/Makefile-default.mk:106: recipe for target 'build/default/production/_ext/1693387515/NeoCol.p1' failed
make[2]: Leaving directory '/home/burt/code/ws8test'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory '/home/burt/code/ws8test'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

BUILD FAILED (exit value 2, total time: 492ms)
For some unknown reason you remove some important C syntax at the end of several lines. This usually results in an error flood.
What's important first is error: (314) ";" expected
 

AlbertHall

Joined Jun 4, 2014
12,640
For some unknown reason you remove some important C syntax at the end of several lines. This usually results in an error flood.
What's important first is error: (314) ";" expected
The if line should have Bit with a capital B, the variable, not the data type.
Lines 5, 6, 7, 11, 12, 13 should have semicolons at the end. C gets very upset if you omit a colon and it tends to point you to somewhere where the error isn't!
 

Thread Starter

be80be

Joined Jul 5, 2008
2,395
Dam I been messing with this too long lol.
It lights them up.
color not changing tho

It's really making color I should say because there only red blue green so it making white blue
 
Last edited:

nerdegutta

Joined Dec 15, 2009
2,689
I have a few questions:

1. Where is NeoNum assigned a value?

2. Why are you using two types of delays? _delay and __delay_ms.

I might be overlooking something... :)
 

Thread Starter

be80be

Joined Jul 5, 2008
2,395
I didn't write the code I found it it said it worked with xc8 I did over look the ;
You have to over look me I've just started with xc8.

I've only got back at xc8 after running my girlfriend off she hated this stuff.

I used swordfish basic.
But I no better been playing a lot with arduino code but it points out missing ;;;; beter.lol
 

Thread Starter

be80be

Joined Jul 5, 2008
2,395
_delay(3); _delay(constant)' to delay for the specified number of instruction cycles
Thanks to AlbertHall for pointing that out.


Where is NeoNum assigned a value?

In the NeoCol.h file
 

AlbertHall

Joined Jun 4, 2014
12,640
It's really making color I should say because there only red blue green so it making white blue
It's driving a three colour LED?
The only output is to NeoPin and all it does is set that pin high for either 3 or 6 cycles. How does that set multiple colours?
 

Thread Starter

be80be

Joined Jul 5, 2008
2,395
Yes it's running just not changing I checked it with my scope
looks about like what his video shows.
 
Top