2379 views|0 replies

1140

Posts

0

Resources
The OP
 

TMS320F280049C Study Notes 4 LED_EX1_BLINKY and initialization function [Copy link]

The reference routine for this experiment is Led_ex1_blinky. You can also follow this step to start learning other types of DSP in the future.

About conditional compilation


In the document [1], there is a description of conditional compilation.
In CCS9.3, the corresponding setting is: CCS9.3 setting


The purpose of this setting is to match different hardware. For the two processors 28379D and 280049C, TI released ControlCARD and LaunchPad respectively. Their crystal oscillators and pin configurations are different. The routine is developed for ControlCARD. If you want to apply it to LaunchPad, you naturally need to change the pin mapping. The specific code can be found in devices.h. Some screenshots are as follows:

Conditional compilation 2
It should be noted that if you define the pins and develop the program completely from scratch, you do not need to pay attention to this part of the conditional compilation instructions.

Routine
This section gives two routines of the LED flashing experiment from the official folder. The first one is the library function programming version, and the second one is the register programming version. It can be seen that there is a significant difference in the calling part of the initialization function.
The LED circuit diagram of the 280049C LaunchPad is as follows:

Library function version:

#include "driverlib.h"
#include "device.h"

#define LOOP_COUNT 10

void main(void)
{
// Initialize clock and peripherals Initialize device clock and peripherals
Device_init();

// Initialize GPIO and configure the GPIO pin as a push-pull output
Device_initGPIO();
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD); // Push-pull output or floating input
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);

// Initialize PIE and clear PIE registers
. Disables CPU interrupts.
Interrupt_initModule();

//
Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
Interrupt_initVectorTable();

// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
EINT;
ERTM;

// Loop Forever
for(;;)
{
// Turn on LED
// The hardware circuit design is that the LED turns on when the GPIO outputs a low level
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);

// Delay 0.5s Delay for a bit.
DEVICE_DELAY_US(500000);

// Turn off LED
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);

// Delay for a bit.
DEVICE_DELAY_US(500000);
}
}

Register version:

#include "F28x_Project.h"

#define DEVICE_GPIO_PIN_LED1 31


void main(void)
{
// Initialize device clock and peripherals
InitSysCtrl();

// Initialize GPIO and configure the GPIO pin as a push-pull output
InitGpio();
GPIO_SetupPinMux(DEVICE_GPIO_PIN_LED1, GPIO_MUX_CPU1, 0);
GPIO_SetupPinOptions(DEVICE_GPIO_PIN_LED1, GPIO_OUTPUT, GPIO_PUSHPULL);

// Initialize PIE and clear PIE registers. Disables CPU interrupts.
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
InitPieVectTable();

// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
EINT;
ERTM;

// Loop Forever
for(;;)
{
// Turn on LED
GPIO_WritePin(DEVICE_GPIO_PIN_LED1, 0);

// Delay for a bit.
DELAY_US(500000);

// Turn off LED
GPIO_WritePin(DEVICE_GPIO_PIN_LED1, 1);

// Delay for a bit.
DELAY_US(500000);
}
}



There are many articles discussing register programming, and we refer to [4] for a summary. The first statement after the main function of the second code is InitSysCtrl (
), which initializes the chip. The declaration of this function is in f28004x_sysctrl.c.

Watchdog
The first sentence of the initialization function is to turn off the watchdog. The specific code is as follows:

void DisableDog(void)
{
volatile Uint16 temp;
EALLOW;

//
// Grab the clock config so we don't clobber it
//
temp = WdRegs.WDCR.all & 0x0007;
WdRegs.WDCR.all = 0x0068 | temp;
EDIS;
}

This code is much better than the previous version. It does not directly assign values, but uses the OR method to avoid destroying other clock settings.
EALLOW is discussed in Section 3.1 of [5].


In Section 3.14.23.4, each bit of the register is explained in detail. Insert the picture description here

According to the manual, the binary number corresponding to turning off the watchdog is 0000 0000 0110 1000, which is 0068 in hexadecimal.

Others
The rest is to initialize Flash, phase-locked loop, and various peripheral clocks. At the current level, this part of the code is still difficult, so it is skipped for now.
In this part, 280049C will involve a term called DCC, the full name is Dual-Clock Comparator, which is mainly used to enhance the reliability of the clock signal. It is discussed in Chapter 6 of [5].

This post is from Microcontroller MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list