hello all,
#include "S32K144.h" /* include peripheral declarations S32K144 */
#include "clocks_and_modes.h"
#include "ADC.h"
#define PTD15 15 /* RED LED*/
#define PTD16 16 /* GREEN LED*/
#define PTD0 0 /* BLUE LED */
void PORT_init (void) {
PCC->PCCn[PCC_PORTD_INDEX ]|=PCC_PCCn_CGC_MASK; /* Enable clock for PORTD */
PORTD->PCR[PTD0] = 0x00000100; /* Port D0: MUX = GPIO */
PORTD->PCR[PTD15] = 0x00000100; /* Port D15: MUX = GPIO */
PORTD->PCR[PTD16] = 0x00000100; /* Port D16: MUX = GPIO */
PTD->PDDR |= 1<<PTD0; /* Port D0: Data Direction= output */
PTD->PDDR |= 1<<PTD15; /* Port D15: Data Direction= output */
PTD->PDDR |= 1<<PTD16; /* Port D16: Data Direction= output */
}
void WDOG_disable (void){
WDOG->CNT=0xD928C520; /* Unlock watchdog */
WDOG->TOVAL=0x0000FFFF; /* Maximum timeout value */
WDOG->CS = 0x00002100; /* Disable watchdog */
}
int main(void)
{
uint32_t adcResultInMv=0;
WDOG_disable(); /* Disable WDOG*/
SOSC_init_8MHz(); /* Initialize system oscillator for 8 MHz xtal */
SPLL_init_160MHz(); /* Initialize SPLL to 160 MHz with 8 MHz SOSC */
NormalRUNmode_80MHz(); /* Init clocks: 80 MHz sysclk & core, 40 MHz bus, 20 MHz flash */
PORT_init(); /* Init port clocks and gpio outputs */
ADC_init(); /* Init ADC resolution 12 bit*/
for(;;) {
convertAdcChan(12); /* Convert Channel AD12 to pot on EVB */
while(adc_complete()==0){} /* Wait for conversion complete flag */
adcResultInMv = read_adc_chx(); /* Get channel's conversion results in mv */
if (adcResultInMv > 3750) { /* If result > 3.75V */
PTD->PSOR |= 1<<PTD0 | 1<<PTD16; /* turn off blue, green LEDs */
PTD->PCOR |= 1<<PTD15; /* turn on red LED */
}
else if (adcResultInMv > 2500) { /* If result > 2.5V */
PTD->PSOR |= 1<<PTD0 | 1<<PTD15; /* turn off blue, red LEDs */
PTD->PCOR |= 1<<PTD16; /* turn on green LED */
}
else if (adcResultInMv >1250) { /* If result > 1.25V */
PTD->PSOR |= 1<<PTD15 | 1<<PTD16; /* turn off red, green LEDs */
PTD->PCOR |= 1<<PTD0; /* turn on blue LED */
}
else {
PTD->PSOR |= 1<<PTD0 | 1<< PTD15 | 1<<PTD16; /* Turn off all LEDs */
}
convertAdcChan(29); /* Convert chan 29, Vrefsh */
while(adc_complete()==0){} /* Wait for conversion complete flag */
adcResultInMv = read_adc_chx(); /* Get channel's conversion results in mv */
}
}
Hope, you understood my question. Please help me out how ever possiblle. Thank You
Hi akhilranga,
Please refer to adc_hwtrigger_s32k144 in S32SDK S32K1xx RTM:
I don't know what version of S32DS you are using. Here are the two latest SDK versions in S32DS ARM2.2 and S32DS 3.4:
S32 Design Studio for ARM 2.2 - Update 1 available
S32 Design Studio v3.4 S32K1 Service Pack 1 released!
Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hello there i am using S32kDS for ARM v1.3.
And i dont have this SDK S32SDK S32K1xx RTM:.
How can i get this.Please asssit me.
Thank You
The version of S32DS you are using is too old, it is recommended to use a new version for development.
Anyway, please install S32K1 SDK by refer to: S32 Design Studio for Arm v1.3 - Update 3 & 4 available
Hi @Robin_Shen
thanks for the advice about the version 1.3
I tried the adc_hwtrigger, but got lots of errors. can you please help me resolve it. Attaching the screen shot down below.
Thank You
Please click "Generate Processor Expert Code" and then Build the project.
Hi @Robin_Shen
Yes, I was able to do build the code without erorr. I jsut had one last doubt . Where can i acess that print function. I mean where can i see the ADC valuse which were being printed by the function.
The example documentation can be found in the S32 SDK documentation at Examples and Demos section. (<SDK_PATH>/doc/Start_Here.html) Please read the manual of ADC Hardware Trigger