Good day! Is the example of assembler code initial DAC in dsc MC56F8037?
Good day! What is not normally in this code:
void initDAC0()
{
asm (move.w #$f08f,X:PIT0_MOD);
asm (move.w #08ff,X:PIT0_CNTR);
asm (move.w #$000f,X:PIT0_CTRL);
asm (bfset #$1000,X:SIM_PCE1);
asm (move.w #$033e,X:DAC0_MAXVAL);
asm (move.w #$f03f,X:DAC0_CTRL);
asm (move.w #$000e,X:DAC0_DATA);
asm (move.w #$0f3e,X:DAC0_STEP);
asm (move.w #$003e,X:DAC0_MINVAL);
}
?
Hi, Constantin,
I think your assembly code is okay to assign a constant to a peripheral register with move.w instruction.
The assembly instruction is described in DSP56F800ERM, pls download it from the website:
MC56F84xxx|Digital Signal Controllers|NXP
BR
XiangJun Rong
Good day!
#pragma interrupt called
void initLED()
{
//---------GpioD
asm(bfclr #$0030,X:GPIOD_PEREN); //#$0000 0000 0000 0011 0000
asm(bfset #$0030,X:GPIOD_DDIR);
asm (bfclr #$0010,X:GPIOD_DATA);
}
void initIsr ()
{
asm (bfclr #$FFFF,X:SIM_IPS1); |
asm(bfset #$00c0,X:GPIOD_PEREN); //DAC0, DAC1 0000 0000 1100 0000
}
Hi, Constantin,
I think your assembly code is correct to configure the GPIO pin and the DAC output pins. Regarding the line "#pragma interrupt called", if the api function is called in an ISR(Interrupt Service Routine), you have to add the line "#pragma interrupt called" before the api function, which will push/pop all the registers the api function uses. If you define the ISR, you have to add "#pragma interrupt on" before the ISR so that the compiler generates the code to push/pop both PC and SR. For your case, it is unnecessary to add "#pragma interrupt called" before initLED() api function.
Hope it can help you.
BR
Xiangjun Rong
Hi, Using CW 8.3 for DSC, I generated a project using Processor Expert Stationery.
I then added the DAC, with the default, for PE, settings.
Here is both the C code and its assembly equivalent generated to initialize the DAC for the 8037 device:
setReg16(DAC0_CTRL, 0x01U);
P:00000105: E418F1C00000 move.l #0xf1c0,R0
P:00000108: 86400001 move.w #1,X:(R0)
/* DAC0_DATA: DATA=0 */
setReg16(DAC0_DATA, 0x00U);
P:0000010A: E418F1C10000 move.l #0xf1c1,R0
P:0000010D: 86400000 move.w #0,X:(R0)
/* DAC0_MAXVAL: MAXVAL=0 */
setReg16(DAC0_MAXVAL, 0x00U);
P:0000010F: E418F1C40000 move.l #0xf1c4,R0
P:00000112: 86400000 move.w #0,X:(R0)
/* DAC0_MINVAL: MINVAL=0 */
setReg16(DAC0_MINVAL, 0x00U);
P:00000114: E418F1C30000 move.l #0xf1c3,R0
P:00000117: 86400000 move.w #0,X:(R0)
/* DAC0_STEP: STEP=0 */
setReg16(DAC0_STEP, 0x00U);
P:00000119: E418F1C20000 move.l #0xf1c2,R0
P:0000011C: 86400000 move.w #0,X:(R0)
/* DAC0_CTRL: PDN=0 */
clrReg16Bits(DAC0_CTRL, 0x01U);
P:0000011E: E418F1C00000 move.l #0xf1c0,R0
P:00000121: 80400001 bfclr #1,X:(R0)