I am designing a DMX LED dimmer around the PIC32MX110F016B part, using MPLAB X and XC32 compiler.
The idea is to use a lookup table to map the incoming 8 bit DMX brightness values to 12 bit PWM values stored in a table.
This scheme will allow me to implement LED gamma correction for much improved brightness linearity.
My program needs 3 tables of 256 values each, one for each color -(R-G-B). Each table entry can be a 32 bit word, but I only need 12 bits of resolution.
I am a veteran assembly programmer and have written this code before in assembly for the PIC18F series parts.
It was simple to use an ORG statement to locate a table of values created using DT or DW (define table or define word)
Programming in C totally freaks me out - I feel like I have NO IDEA what is going on under the hood, like I did in assembly, the compiler just holds my hand and leads me into the dark.
I know I can simply create a STATIC CONSTANT array in C, that seems simple, but I need to be able to change the data by erasing and re-writing the flash memory in the field, using the serial port and a special command mode.
1) How can I tell the compiler where to locate the STATIC CONSTANT array so I can erase and re-write it later?
It should be located on a page boundary so I can block-erase the table before writing new values.
2) Can I use in-line assembly to do the same trick? then use a crude pointer trick to fetch the values?
3) How do I tell the compiler to not use that memory area for other code?
The idea is to use a lookup table to map the incoming 8 bit DMX brightness values to 12 bit PWM values stored in a table.
This scheme will allow me to implement LED gamma correction for much improved brightness linearity.
My program needs 3 tables of 256 values each, one for each color -(R-G-B). Each table entry can be a 32 bit word, but I only need 12 bits of resolution.
I am a veteran assembly programmer and have written this code before in assembly for the PIC18F series parts.
It was simple to use an ORG statement to locate a table of values created using DT or DW (define table or define word)
Programming in C totally freaks me out - I feel like I have NO IDEA what is going on under the hood, like I did in assembly, the compiler just holds my hand and leads me into the dark.
I know I can simply create a STATIC CONSTANT array in C, that seems simple, but I need to be able to change the data by erasing and re-writing the flash memory in the field, using the serial port and a special command mode.
1) How can I tell the compiler where to locate the STATIC CONSTANT array so I can erase and re-write it later?
It should be located on a page boundary so I can block-erase the table before writing new values.
2) Can I use in-line assembly to do the same trick? then use a crude pointer trick to fetch the values?
3) How do I tell the compiler to not use that memory area for other code?