32528_1489253934 0 Posted December 10, 2014 Share Posted December 10, 2014 Hello There, I have modified one of the example files from Proffesor Valvano, I've got this file from: http://users.ece.ute...m/PWM_4C123.zip I have modified PWM0A_Init so I can see the output on PF3 (Green Led), here the most right comments indicate the changes that I have made: void PWM0A_Init(unsigned short period, unsigned short duty){ volatile unsigned long delay; SYSCTL_RCGCPWM_R |= 0x01<<1; // 1) activate PWM0 >>activate PWM1 SYSCTL_RCGCGPIO_R |= 0x01<<5; // 2) activate port B >> activate port F delay = SYSCTL_RCGCGPIO_R; // allow time to finish activating >> Remains the same GPIO_PORTF_AFSEL_R |= 0x01<<3; // enable alt funct on PB6 >> set bit 3 GPIO_PORTF_PCTL_R &= ~0xF000; // configure PB6 as PWM0 >> Clear PMC3 GPIO_PORTF_PCTL_R |= 0x5000; // >> to x5 on PCTL GPIO_PORTF_AMSEL_R &= ~0x08; // disable analog functionality on PB6 >> on bit 3 GPIO_PORTF_DEN_R |= 0x01<<3; // enable digital I/O on PB6 >> on bit 3 SYSCTL_RCC_R |= SYSCTL_RCC_USEPWMDIV; // 3) use PWM divider >> Remains the same SYSCTL_RCC_R &= ~SYSCTL_RCC_PWMDIV_M; // clear PWM divider field >> Remains the same SYSCTL_RCC_R += SYSCTL_RCC_PWMDIV_2; // configure for /2 divider >> Remains the same PWM1_3_CTL_R = 0; // 4) re-loading down-counting mode >> to M1G3 PWM1_3_GENB_R = (PWM_3_GENB_ACTCMPAD_ONE|PWM_3_GENB_ACTLOAD_ZERO);// >> to M1 G3 B // PB6 goes low on LOAD // PB6 goes high on CMPA down PWM1_3_LOAD_R = period - 1; // 5) cycles needed to count down to 0 >> period=4000 PWM1_3_CMPB_R = duty - 1; // 6) count value when output rises >> duty=3000, M1 G3 B PWM1_3_CTL_R |= 0x01; // 7) start PWM0 >> M1G3, same value x01 PWM1_ENABLE_R |= 0x01<<7; // enable PB6/M0PWM0 >> M1, PWM7EN} I have not change anything major, I only changed the: Port, PWM module and generator.....but I can't manage to get anything out from the logic analizer. Btw the function is called with the following values: PWM0A_Init(40000, 30000); Please if you could give me any suggestions , I cant see what im missing crom Quote Link to post Share on other sites
Lyon 3 Posted December 10, 2014 Share Posted December 10, 2014 Hi, PF3 is on PWM module 1 - PWM7 - so please see what you need to use in chapter PWM of your user manual - and decide then corrections/modifications. L Quote Link to post Share on other sites
32528_1489253934 0 Posted December 12, 2014 Author Share Posted December 12, 2014 Hi, PF3 is on PWM module 1 - PWM7 - so please see what you need to use in chapter PWM of your user manual - and decide then corrections/modifications. L Hi Lyon, Well that is exactly what I have done, if you see the rightmost comments are mine ... I did change the values according with data sheet, i went through several times but I can not spot the mistake. Thanks for you interest, crom Quote Link to post Share on other sites
Lyon 3 Posted December 14, 2014 Share Posted December 14, 2014 Hi, In this case, I suggest to download/install/run the application Pinmux from TI - select then your micro type, configure the pins as you need and the application will generate the initialization code for you. Then compare with your code. Take care will be different, since the Pinmux uses driverlib - you may replace your code or you may inspect the functions used there to see the registers used to initialize the pins. L Quote Link to post Share on other sites
32528_1489253934 0 Posted December 15, 2014 Author Share Posted December 15, 2014 Hi, In this case, I suggest to download/install/run the application Pinmux from TI - select then your micro type, configure the pins as you need and the application will generate the initialization code for you. Then compare with your code. Take care will be different, since the Pinmux uses driverlib - you may replace your code or you may inspect the functions used there to see the registers used to initialize the pins. L Hi Lyon, Thanks for your reply, I have tested the Pin Mux utility before....but it generates the Tivaware sort of code: MAP_GPIOPinConfigure(GPIO_PF3_M1PWM7); It would be handy to have the PinMux Utility to generate code that it is consistent with the datasheet!!!, so in general I can realy use it. Please If you have any more suggestions, please let me know. Greets, crom Quote Link to post Share on other sites
Lyon 3 Posted December 15, 2014 Share Posted December 15, 2014 Hi, But the driverlib functions are consistent with the user manual! In general, it is useful to use these instead direct register addressing, for fast programming. This will ease your work. Some other people may comment that this is time consuming. If it is your case, at least look at them and use the function content, without wrapping (some time is really spent in those functions - the ASSERT takes some time, but once the program is debugged, these can be removed). Sometime it is really more convenient to use direct registers - but after you have more experience with this micro. In your case: to get your result, use the code generated by Pinmux utility. take care and look/use at all #include declarations in those files. Add the following global symbols to avoid any compilation/linking errors: DEBUG CLASS_IS_TM4C123 PART_TM4C123GH6PM TARGET_IS_BLIZZARD_RA1 gcc if you use GCC/Energia, ccs="ccs" (CCS), ewarm (IAR), rmvdk (Keil). MAP_ prefix can be removed and in this case pure driverlib functions will be used or if you keep it, then functions available in ROM will be used if available, otherwise from driverlib. Try and tell the result (and the tools used if still with problems) L Quote Link to post Share on other sites
32528_1489253934 0 Posted December 16, 2014 Author Share Posted December 16, 2014 Hi, But the driverlib functions are consistent with the user manual! In general, it is useful to use these instead direct register addressing, for fast programming. This will ease your work. Some other people may comment that this is time consuming. If it is your case, at least look at them and use the function content, without wrapping (some time is really spent in those functions - the ASSERT takes some time, but once the program is debugged, these can be removed). Sometime it is really more convenient to use direct registers - but after you have more experience with this micro. In your case: to get your result, use the code generated by Pinmux utility. take care and look/use at all #include declarations in those files. Add the following global symbols to avoid any compilation/linking errors: DEBUG CLASS_IS_TM4C123 PART_TM4C123GH6PM TARGET_IS_BLIZZARD_RA1 gcc if you use GCC/Energia, ccs="ccs" (CCS), ewarm (IAR), rmvdk (Keil). MAP_ prefix can be removed and in this case pure driverlib functions will be used or if you keep it, then functions available in ROM will be used if available, otherwise from driverlib. Try and tell the result (and the tools used if still with problems) L Hey Lyon, Thanks for your interest. I started with one method and I will stick to it, so far I have been following Valvano's videos and Books...I am already getting used to the registers and datasheet. Btw so far i do not have any errors, it just does not drive the LED as expected. Greets, crom Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.