完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
ADC的问题,不知道是不是9B96的问题还是我程序的问题。
void adc1Init(void) [ // SysCtlPeripheralEnable(GPIO_PORTB_BASE); //GPIOPinTypeADC(GPIO_PORTB_BASE,GPIO_PIN_4 ); ADCSequenceDisable(ADC1_BASE,3); // 配置前先禁止采样序列 SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); // 使能ADC模块 SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS); // 设置ADC采样速率 // 采样序列配置:ADC基址,采样序列编号,触发事件,采样优先级 ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 1); // 采样步进设置:ADC基址,采样序列编号,步值,通道设置 ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_END | ADC_CTL_IE ) ; ADCReferenceSet(ADC1_BASE,ADC_REF_INT); ADCResolutionSet(ADC1_BASE,ADC_RES_10BIT) ; ADCIntClear(ADC1_BASE, 3); ADCSequenceEnable(ADC1_BASE, 3); // 使能采样序列 ADCIntEnable(ADC1_BASE, 3); // 使能ADC中断 IntEnable(INT_ADC1SS3) ; // 使能ADC采样序列中断 IntMasterEnable() ; // 使能处理器中断 ] 在DKLM3S9B96上跑的。换ADC0就能工作,换ADC1就不能工作。调用这个初始化函数,程序就会死在里面。何解?中断向量也注册了 |
|
相关推荐
1 个讨论
|
|
参考例程如下:
//***************************************************************************** #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "driverlib/timer.h" #include "utils/ustdlib.h" #include "utils/uartstdio.h" #include "driverlib/sysctl.h" #include "driverlib/systick.h" #include "utils/cmdline.h" void Delay(unsigned long count ) [ unsigned i,j; for(i=0;i int iADC0_read=1; // Indicates if the ADC is ready (1) or busy (0) unsigned long ulBlinkSpeed = 0; // Timer interrupt frequency (0=low; 1=high) //************ User Defines ************ // // 12-bit resolution bit // //#define ADC_RES_12BIT 0x10 // // Offset for ADC control register // #define ADC_O_CTL 0x38 //***************************************************************************** // Interrupt handler for the Timer0 interrupt //***************************************************************************** void Timer0IntHandler(void) [ unsigned long ulPinStatus; // Clear the timer interrupt. TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Read the current state of the output ulPinStatus = GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_0); // Toggle Bit 0 ulPinStatus ^= GPIO_PIN_0; // Write the result back into the GPIO Pin 0 Data Register GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, ulPinStatus); // Check if the ADC is ready if (iADC0_read == 1) [ // Trigger new ADC Conversion using Sample Sequencer 0 ADCProcessorTrigger(ADC1_BASE,2); // Indicate that the ADC is busy iADC0_read = 0; ] ] //***************************************************************************** // Interrupt handler for the ADC Sample Sequencer 2 (SS2) interrupt //***************************************************************************** void ADC2IntHandler(void) [ unsigned long adc0Value[4]=[0,0,0,0]; // Holds the ADC result char adc0String[4]; // Holds the string-converted ADC result unsigned long InputVoltage; //Input voltage // Clear the ADC0 interrupt. ADCIntClear(ADC1_BASE,2); // Read the data from the Result Buffer of ADC SS2 // We know that we have only one result in the buffer // If we have more than one result then adc0_value must be an array ADCSequenceDataGet(ADC1_BASE, 2,adc0Value); //ADC AT 12 BIT MODE,PLEASE REFER TO ADC CONVERSION VALUE Y=1352X+28 =>INPUT VOLTAGE VALUE X=((Y-28)/1352)*1000(MV) InputVoltage= (adc0Value[0]-28/1352)*1000; // Delay(6553000); //adc0Value[1]=((1475 * 1023) - (2250 * adc0Value[1])) / 10230; //centigrade temperature IntMasterDisable(); UARTprintf("n%d",adc0Value[0]); UARTprintf("n%d",adc0Value[1]); //UARTprintf("n%d",adc0Value[2]); //UARTprintf("n%d",adc0Value[3]); // Disable interrupts globally to ensure we don't interrupt communication with the display //IntMasterDisable(); iADC0_read = 1; // while(1); // Re-enable interrupts globally IntMasterEnable(); ] int main(void) [ //***************************************************************************** // Clock Setup //***************************************************************************** // Set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_4| SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // Enable Timer 0, ADC0 and GPIO Block D Peripheral Clocks SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); //LED on PD0 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // Reset the state of Peripheral ADC0 // //SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0); // // Setup the AIN0 on PE7 ... // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); //GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_6); //GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_5); // GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_4); // Enable the peripherals used by this example. // IntMasterDisable(); // // Set GPIO A0 and A1 as UART. // GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Initialize the UART as a console for text I/O. // UARTStdioInit(0); // // Print hello message to user. // UARTprintf("nnADC Test Example Programn"); //***************************************************************************** // GPIO Setup //***************************************************************************** // Set GPIO_F, pin 0 as output (used for the LED) GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0); // Disable processor interrupts IntMasterDisable(); //***************************************************************************** // Timer 0 Setup //***************************************************************************** // Configure Timer0 as 32-bit periodic timer TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); // Set Timer0 period as 1/4 of the system clock, i.e. 4 interrupts per second TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet() /4); // Configure the timer to generate an interrupt on time-out TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Enable the TImer Interrupt in the NVIC IntEnable(INT_TIMER0A); // Enable the timer TimerEnable(TIMER0_BASE, TIMER_A); // // Set 12-bit resolution // HWREG(ADC1_BASE + ADC_O_CTL) = HWREG(ADC1_BASE + ADC_O_CTL)| ADC_RES_12BIT; // ADCSequenceConfigure(ADC1_BASE,2, ADC_TRIGGER_PROCESSOR, 0); ADCHardwareOversampleConfigure(ADC1_BASE,16); ADCSequenceStepConfigure(ADC1_BASE, 2,0, ADC_CTL_CH0); //ADC0 channel 0 ADCSequenceStepConfigure(ADC1_BASE, 2,1, ADC_CTL_TS|ADC_CTL_IE | ADC_CTL_END ); //setup temperature channel // Clear the ADC0 interrupt. ADCIntClear(ADC1_BASE,2); ADCIntEnable(ADC1_BASE, 2); // Enable ADC SS2 ADCSequenceEnable(ADC1_BASE, 2); // Enable the ADC0 interrupt in the NVIC IntEnable(INT_ADC1SS2); // Indicate that ADC SS2 is ready for sampling iADC0_read = 1; //***************************************************************************** // Global Interrupt Enable //***************************************************************************** // Enable processor interrupts IntMasterEnable(); IntPrioritySet(INT_TIMER0A,0x40); IntPrioritySet(INT_ADC1SS2,0x40); // Loop forever waiting for interrupts while(1) [ ] ] |
|
|
|
|
|
只有小组成员才能发言,加入小组>>
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
644 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
586 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1039 浏览 1 评论
712 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
510 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
147浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
114浏览 14评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
118浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
114浏览 12评论
TPA6304-Q1: TPA6304 两片公用一组I2C的话,其中一片配置不成功怎么办
157浏览 10评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-17 14:14 , Processed in 0.547474 second(s), Total 46, Slave 37 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号