Setting text as C Code formatting doesn't always work. (Insert/Edit Code)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

In a post I inserted C code using the "Insert/Edit Code" feature and selecting "C"

The inserted text showed up with C format while in edit mode.

Once I posted it to the forum, the formatting was removed.

 

CY_ISR(ISR_SAW_GENERATOR) {
    static uint8_t tbl_idx = 0;

    PWM_UPDATE_INTERRUPT_REQ_REG = PWM_UPDATE_INTR_MASK_TC; // ClearInterrupt
    
    uint32_t msb = saw[((tbl_idx++) & 127)];
    UPDATE_DR |= UPDATE_MASK;
    PWM_MSB_COMP_CAP_BUF_REG = msb;  /* Load the Compare Buffer for the swap */
    UPDATE_DR &= ~UPDATE_MASK;
}

 

It appears to work in the above example.

However check out my posting in this link: PSoC4-PWM-bug-Glitch-on-Compare-Reg-Write 

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
1 Solution

Sara and Dheeraj,

It happened again in another post.  (C formatting colors were lost).

However, performing an immediate page Refresh (F5), the issue disappeared (Color formatting reappeared).

Annoying but easily solvable.

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

4 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Hello @Len_CONSULTRON ,

Thanks for the feedback. I'm not sure why it might be happening. I tried it at my end and it seems to work for me. Perhaps the source of the code might be leading to inconsistencies? I tried pasting from PSoC Creator and ModusToolbox and I didn't see any issues. Where do you copy it from? 

Nevertheless, we will investigate this further and fix it. 

Regards,
Dheeraj

Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Dheeraj,

The code came from Creator.

Strange.  I looked back at the posting and the formatting was shown in "C".  When I had posted it, the "C" formatting was missing.  Now it's there.

Here's another annoying thing:  If there is tabs in the "C" code, the tabs are stripped out.   This forces me to indent with SPACES.

Len
"Engineering is an Art. The Art of Compromise."
SaraLeslie
Community Manager
Community Manager
Community Manager
250 sign-ins 100 sign-ins 50 likes received

Hello Len and Team, 

I will look into this. I agree there are some nuances with the new platform that sometimes make more complicated postings tedious. Thank you for your patience and I will see if I can find any tips to help peoples experience/set expectations with some things. 

Appreciate your attention to detail!

Sara 

Community Manager
0 Likes

Sara and Dheeraj,

It happened again in another post.  (C formatting colors were lost).

However, performing an immediate page Refresh (F5), the issue disappeared (Color formatting reappeared).

Annoying but easily solvable.

Len
"Engineering is an Art. The Art of Compromise."