• AVR Freaks

Hot!PIC18F27Q43 Neopixel Interface "Union/Struct" error

Author
kylel_
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2020/02/21 16:04:43
  • Location: 0
  • Status: offline
2020/04/22 23:08:13 (permalink)
0

PIC18F27Q43 Neopixel Interface "Union/Struct" error

Hello,
 
I am trying to use a PIC18F27Q43 PIC to control a strip of Neopixels, which have an incredibly specific timing requirement. Unfortunately, my issue lies in a different area. I am getting this error when I try to run my code
 
"main.c:15:22: error: member reference base type 'volatile unsigned char' is not a structure or union"
 
I think it has something to do with the fact that I am using the while function in line 8, 10, and 12 to evaluate a register that does not return a binary value. However, I have no idea what "SPI1STATUS.TXBE" returns, and the data sheet does not help much (I assumed it was a bool showing if the TX buffer was empty or not). 
 
If anybody can help me with this error that would be great. 
 
#include "mcc_generated_files/mcc.h"



void writePixel(u_int8 r,u_int8 g,b){

    SPI1TXB = g;
    while(!SPI1STATUS.TXBE);
    SPI1TXB = r;
    while(!SPI1STATUS.TXBE);
    SPI1TXB = b;//SSP1BUF
    while(!SPI1STATUS.TXBE);
    
}



void main(void)
{
  
    while(1){
        writePixel(0,255,0);
    }
}

#1

4 Replies Related Threads

    1and0
    Access is Denied
    • Total Posts : 11501
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC18F27Q43 Neopixel Interface "Union/Struct" error 2020/04/22 23:26:15 (permalink)
    +1 (1)
    Try
    SPI1STATUSbits.TXBE

    #2
    kylel_
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2020/02/21 16:04:43
    • Location: 0
    • Status: offline
    Re: PIC18F27Q43 Neopixel Interface "Union/Struct" error 2020/04/22 23:33:17 (permalink)
    0
    @1and0 thank you. This fixed my compile error, sonow that the device can be programmed. However, it is not outputting a signal from my device. I am using a SPI, PWM, and CLC peripheral to create a signal capable of the timing specs of the WS2812 strip. With my peripherals set up however, and the code I showed earlier running, the output on my CLC1 pin is nothing. Do you know why this might be? 
    #3
    thecucarachon
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2020/10/17 16:40:32
    • Location: 0
    • Status: offline
    Re: PIC18F27Q43 Neopixel Interface "Union/Struct" error 2020/10/20 09:29:59 (permalink)
    0
    Check the code completion tab (Tools - > Options - > Editor). When you enter the point the editor it should suggest the registers of the union/struct, using this feature you shouldn't have any more problems.
    Sorry I edit the post, I put my question in the corresponding place.
    Slds
    post edited by thecucarachon - 2020/10/20 09:50:06
    #4
    1and0
    Access is Denied
    • Total Posts : 11501
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC18F27Q43 Neopixel Interface "Union/Struct" error 2020/10/20 09:48:46 (permalink)
    +1 (1)
    thecucarachon
    Hello, I have a problem with a PIC18F47Q43 where I am trying to generate the pulse for the ws2812 (Neopixel) LEDs by hardware. I am following this microchip tutorial (https://www.youtube.com/watch?v=hHLMnJs87VE), but there are already things that do not match the mcc. I can't assign the timer2 to the pwm, and the tmr postcaler can't go to the SPI either. Does anyone know how I can accommodate this?

    Thanks!




    Duplicate:  https://www.microchip.com.../m1155783.aspx#1155783
    #5
    Jump to:
    © 2020 APG vNext Commercial Version 4.5