Jump to content
  • 0

How do I set LD1 and LD4 on at the same time chipKIT WiFire PIC32MZ2048EFG100


FlyingBlindOnARocketCycle

Question

hi

Im trying to do a simple hello world by turning on the LED's.  It appears that I can not assert two bits in a single register if calling them by name.

The below WILL light all four LEDs as it cycles through them faster than the human flicker fusion rate.

    while(1){
    PORTGbits.RG15 = 1;
    PORTGbits.RG6 = 1;
    PORTBbits.RB11 = 1;
    PORTDbits.RD4 = 1;
    }

If I do this
    PORTGbits.RG15 = 1;
    PORTGbits.RG6 = 1;
    PORTBbits.RB11 = 1;
    PORTDbits.RD4 = 1
    while(1)

The only RG# led that stays lit is the last one.  Can I not write to the bits of a register individually?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

If you want to set both pins at the same time, rather than in two separate statements, you could also do this:

LATGSET = (1 << 15) | (1 << 6);  // or 0b1000000001000000

These parts have registers that can do an atomic set/clear/invert, so that you don't have to do a read/modify/write of the register.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...