Im using the XMC1100 boot kit board, and attempting to toggle the on board leds with an interrupt generated by the CC4 timers. While using the XMClib rather than the Dave Apps. im not 100% sure where im going wrong in my code, and still a bit confused on all of the functions required to get a simple timer , and interrupt generated. Could someone go through my code, maybe point out where im going wrong, and also point out the bare min for a simple timer/ interrupt generation while im learning how to use the CC4?
The current code compiles with no errors, but the LED will turn on, but never toggles, so im assuming the interrupt is never being called.
Code below.
#include "stdio.h"
#include "DAVE.h" //Declarations from DAVE Code Generation (includes SFR declaration)
#include <xmc_ccu4.h>
#include <xmc_gpio.h>
#include <xmc_scu.h>
#define MODULE_PTR CCU40 //Module
#define MODULE_NUMBER (0U) //Unsure
#define SLICE0_PTR CCU40_CC40 //Specific Slice in module CCU 40
#define SLICE0_NUMBER (0U) //Slice #?
#define SLICE0_OUTPUT P0_0
#define LED P0_5
#define LED2 P0_6
// APP START
void toggle(void){
XMC_GPIO_ToggleOutput(LED2);
XMC_GPIO_ToggleOutput(LED);
}
// SYSTEM CLOCK CONFIG
XMC_SCU_CLOCK_CONFIG_t sclk =
{
.pclk_src=XMC_SCU_CLOCK_PCLKSRC_DOUBLE_MCLK,
.rtc_src=XMC_SCU_CLOCK_RTCCLKSRC_DCO2,
.fdiv = 0,
.idiv = 4,
};
XMC_CCU4_SLICE_COMPARE_CONFIG_t timer = {
.timer_mode = (uint32_t)XMC_CCU4_SLICE_TIMER_COUNT_MODE_EA,
.monoshot = (uint32_t)XMC_CCU4_SLICE_TIMER_REPEAT_MODE_REPEAT,
.shadow_xfer_clear = false,
.dither_timer_period = false,
.dither_duty_cycle = false,
.prescaler_mode = (uint32_t)XMC_CCU4_SLICE_PRESCALER_MODE_NORMAL,
.mcm_enable = false,
.prescaler_initval = XMC_CCU4_SLICE_PRESCALER_4096,
.float_limit = 0,
.dither_limit = 0,
.passive_level = XMC_CCU4_SLICE_OUTPUT_PASSIVE_LEVEL_LOW,
.timer_concatenation = false
};
XMC_CCU4_SLICE_EVENT_CONFIG_t SLICE0_event0_config=
{
.mapped_input = XMC_CCU4_SLICE_INPUT_I, /* mapped to SCU.GSC40 */
.edge = XMC_CCU4_SLICE_EVENT_EDGE_SENSITIVITY_RISING_EDGE,
.level = XMC_CCU4_SLICE_EVENT_LEVEL_SENSITIVITY_ACTIVE_HIGH,
.duration = XMC_CCU4_SLICE_EVENT_FILTER_3_CYCLES
};
int main(void)
{
XMC_SCU_CLOCK_Init(&sclk);
XMC_CCU4_Init(CCU40_CC40, XMC_CCU4_SLICE_MCMS_ACTION_TRANSFER_PR_CR);
XMC_CCU4_SetModuleClock(CCU40_CC40, XMC_CCU4_CLOCK_SCU);
XMC_CCU4_SLICE_CompareInit(CCU40_CC40, &timer);
XMC_CCU4_SLICE_SetTimerCompareMatch(CCU40_CC40, 10);
XMC_CCU4_SLICE_SetTimerPeriodMatch(CCU40_CC40, 20);
XMC_CCU4_EnableShadowTransfer(CCU40, XMC_CCU4_SHADOW_TRANSFER_SLICE_0);
XMC_CCU4_SLICE_EnableEvent(CCU40_CC40, XMC_CCU4_SLICE_IRQ_ID_COMPARE_MATCH_UP);
XMC_CCU4_SLICE_SetInterruptNode(CCU40_CC40, XMC_CCU4_SLICE_IRQ_ID_COMPARE_MATCH_UP, XMC_CCU4_SLICE_SR_ID_0);
XMC_CCU4_EnableClock(CCU40_CC40, (0U));
NVIC_SetPriority(CCU40_0_IRQn, 3U);
NVIC_EnableIRQ(CCU40_1_IRQn);
XMC_CCU4_SLICE_StartTimer(CCU40_CC40);
//On Board LED Config
XMC_GPIO_CONFIG_t OBL =
{
OBL.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
OBL.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH,
};
//Pin Initialize
XMC_GPIO_Init(LED, &OBL);
XMC_GPIO_Init(LED2, &OBL);
XMC_GPIO_SetOutputLow(LED);
}
void IRQ_Hdlr_22(void)
{
toggle();
};
Show Less
Hi I have a college project about a accelerometer taking measures from X,Y,Z axis and then turning some lights on when i move my accelerometer in those axis. I'm new to XMC and I'm having some issues with I2C in general. I want to receive data and write data, and for now I'm just trying the WHO_AM_I register to see if I can receive some result, but I always get stuck in my while loops.
Work Down here.
Show Less
I would like to program the GAP interface of the BLE CYBLE 416045-02, Where could i get documentation and examples?
Where can I find CAD and PLECS model for the FS380R12A6T4BBPSA1?
Hello Sampath,
Could you please suggest suitable XMC Series Controller Eval Board for controlling 48VDC BLDC Motor for E-Vehicles application. We have Card for Driver and MOSFET side. We just need Controller and reference FW to control BLDC Motor. Please response ASAP.
Show LessHello everyone,
I have a question. Why is there a string of code at the bottom of the chip? How can this happen? Who knows and tells me why???
Look forward to your reply.
Your soon feedback would be appreciated.
Thank you very much.
Best regards,
Qunt Chen
The CCU8 timers on the XMC4400 and 4700 have a strange quirk when in center-aligned PWM mode.
When setting the duty cycle to 0%, the reference manual says "generating a 0% duty cycle signal is always possible by setting a value in the compare register bigger than the one programmed into the period register". The quirk affects how the complementary output is generated in this case.
If you program the compare register with the value in the period register + 1 things work as expected, and the complementary output appears as a 100% duty cycle signal. If you set it to anything larger, such as period register + 2, the complementary output appears as either a glitch or as a 0% duty cycle some of the time. This is not consistent--sometimes the complementary output is 100% (as expected) and sometimes it just glitches or stays low.
The manual should say "generating a 0% duty cycle signal is always possible by setting a value in the compare register to the one programmed into the period register + 1". Setting it to "a value in the compare register bigger than the one programmed into the period register" will cause problems in the complementary output.
Show LessHi,
I have an issue such that when I play audio via A2DP or have an open SCO connection the HCI UART interface stops working.
When I stop the audio stream the HCI interface resumes operation.
BR,
Oskar
Show LessI’m using the EZ USB FX2LP Discovery Kit with Windows 10. I found the set of drivers in this forum, and did have the driver working once. But now, when I connect to the board, a window comes up that states “USB Device Not Recognized”. In Device Manager under “Universal Serial Bus controllers” it shows up as “Cypress FX2LP No EEPROM Device” but has the triangle exclamation point symbol. Under Device status it shows “This device cannot start. (Code 10) A request for the USB device descriptor failed.”
I tried to update the driver again but still get the same error. Any suggestions?
Show LessUser | Count |
---|---|
1241 | |
564 | |
436 | |
429 |
Level 9
Level 10
Level 9
Level 9
Level 7
Level 9