Jump to content

Sahil

Members
  • Content Count

    11
  • Joined

  • Last visited

About Sahil

  • Rank
    Member

Profile Information

  • Gender
    Male
  1. Sahil

    TivaWare Errors

    I have no experience with energia so try to make sure the the driver libraries paths are correctly defined in settings.
  2. Sahil

    Initializing ADC0, jumps to Fault ISR

    Dear all, The problem has been fixed by introducing the PLL. i.e. SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
  3. Hello all, I am stuck in initialization of the ADC, all that code used to work but now it just stopped working.This code is working fine in Keil IDE and also used to work in CCS. I tried to debug the code and found at the following instruction it jumps to Fault ISR. ADCSequenceDisable(ADC0_BASE, 0); //ADC0_ACTSS_R &= ~(ADC_ACTSS_ASEN0); //Disable Sample Squencer0 before configuring it</span>I also tried to use the direct register access as mentioned above in commented text, but no luck. The whole code of the program is; int main(void) { volatile unsigned int ulLoop; volatile unsigned long adcvalue; SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); ulLoop = SYSCTL_RCGC2_R; //Some delay to stabilize the clock on the GPIO E and F modules initadc(); adcvalue = readadc(AIN8); //PE5 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ulLoop = SYSCTL_RCGC2_R; //Some delay to stabilize the clock GPIO_PORTF_DIR_R |= 0x0EU; GPIO_PORTF_DEN_R |= 0x0EU; GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 |GPIO_PIN_3); while(1) { GPIO_PORTF_DATA_R = 0x00; GPIO_PORTF_DATA_R |= LED_RED; for(ulLoop = 0; ulLoop < 1800000; ulLoop++){ } // Delay GPIO_PORTF_DATA_R = 0x00; for(ulLoop = 0; ulLoop < 1800000; ulLoop++){ } GPIO_PORTF_DATA_R |= LED_GREEN; for(ulLoop = 0; ulLoop < 1800000; ulLoop++){ } GPIO_PORTF_DATA_R = 0x00; for(ulLoop = 0; ulLoop < 1800000; ulLoop++){ } GPIO_PORTF_DATA_R |= LED_BLUE; for(ulLoop = 0; ulLoop < 1800000; ulLoop++){ } } } and the initadc function is as follow; #include "inc/hw_types.h" #include "inc/lm4f120h5qr.h" #include "driverlib/debug.h" #include "driverlib/adc.h" #include "inc/hw_memmap.h" #include "driverlib/sysctl.h" /*initadc() function initializes ADC0 and partially initializes Sample Sequencer 0. It doesnt assign the required adc channel pin.*/ void initadc(void) { volatile unsigned int ulLoop; //configuring ADC0 module SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlADCSpeedSet(SYSCTL_ADCSPEED_250KSPS); ulLoop = SYSCTL_RCGC0_R; //Stabilize the clock //SYSCTL_RCGC0_R |= SYSCTL_RCGC0_ADC0SPD_250K; //Configure ADC0 to sample at 250kHz //SYSCTL_RCGC0_R |= SYSCTL_RCGC0_ADC0; //Enable clock to ADC0 Module //Configuring Sample Squencer 0 ADCSequenceDisable(ADC0_BASE, 0); //ADC0_ACTSS_R &= ~(ADC_ACTSS_ASEN0); //Disable Sample Squencer0 before configuring it //Configuring Sample Squencer priorities ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); //ADC0_SSPRI_R = (ADC_SSPRI_SS0_1ST | ADC_SSPRI_SS1_2ND | ADC_SSPRI_SS2_3RD | ADC_SSPRI_SS3_4TH); //Select Event triggering mode e.g Process triggered, Timer triggered, GPIO triggered etc //ADC0_EMUX_R = (ADC_EMUX_EM0_PROCESSOR); //Process triggered /* //Configuring the squence steps (i.e. assigning the adc channels (e.g. AIN0 is adc channel 0 = PE3 pin) that is to read) ADC0_SSMUX0_R &= ~(0x0000000F); //Clear MUX0 field //Here we can add multiple ADC channels by configuring ADCSSMUX0 register of SS0// ADC0_SSMUX0_R |= 0x00000001; //Select AIN1 i.e. PE2 as a first sample of the sample sequencer 0 //Configuring sample sequencer 0 control //In case of more then one ADC channel used in SS0. END bit of ADCSSCTL0 register should be made active for the last sample// ADC0_SSCTL0_R = ADC_SSCTL0_END0 | ADC_SSCTL0_IE0; //First sample is END of sampling and interupt is enabled on completing first sample //Enable the Sample Sequencer 0 ADC0_ACTSS_R |= (ADC_ACTSS_ASEN0); */ // Enable the GPIO Port E. PortE is used with AIN8 i.e. PE5 as ADC pin SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOE; ulLoop = SYSCTL_RCGC2_R; //Stabilize the clock GPIO_PORTE_DIR_R &= ~0x10; // 2) make PE5 input GPIO_PORTE_AFSEL_R |= 0x10; // 3) enable alternate function on PE5 GPIO_PORTE_DEN_R &= ~0x10; // 4) disable digital I/O on PE5 GPIO_PORTE_AMSEL_R |= 0x10; // 5) enable analog function on PE5 } /*long readadc(int) partially initialized the Sample Squencer 0 and assigns the required adc channel pin*/ unsigned long readadc(unsigned int channel) { volatile unsigned long result; ADC0_SSMUX0_R |= channel; //Select channel i.e. AINn i.e. PE2 as a first sample of the sample sequencer 0 //Configuring sample sequencer 0 control //ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END); //ADC0_SSCTL0_R = ADC_SSCTL0_END0 | ADC_SSCTL0_IE0; //First sample is END of sampling and interupt is enabled on completing first sample //Enable the Sample Sequencer 0 ADC0_ACTSS_R |= (ADC_ACTSS_ASEN0); //initiate SS0 ADC0_PSSI_R = 0x01; //0x01=SS0, 0x02=SS1, 0x04=SS2, 0x08=SS3 //Wait for interupt for SS0 conversion complete while((ADC0_RIS_R&0x01)==0) {//Do nothing } result = ADC0_SSFIFO0_R; // Acknowlodgement the interupt for SS0 ADC0_ISC_R |= 0x01; //Return the result return result; }
  4. Sahil

    GPIO Interrupt Question

    Though the post is a bit old, I am sharing my code that might be useful for someone googling for something similar. /* This program uses an interrupt routin to toggle the LEDs when SW1 (connected to PF4 pin) is pressed. The program remains in forground thread till it receive the interrupt request by pressing SW1, it jumps to the backgrouind thread i.e. IntGPIOF ISR and performs the task and comes back to the forground thread */ #define TARGET_IS_BLIZZARD_RA1 //This is required for Keil IDE in order to compile the code with ROM_ functions #include "inc/hw_types.h" #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "lm4f120h5qr.h" #include "driverlib/sysctl.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #define LED_RED 0x02 //PF1(Red) #define LED_BLUE 0x04 //PF2(Blue) #define LED_GREEN 0x08 //PF3(Green) extern void IntGPIOF(void); int main(void) { volatile int ulLoop; ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ulLoop = SYSCTL_RCGC2_R; //Some delay to stabilize the clock on the GPIO module GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 |GPIO_PIN_3); GPIOPortIntRegister(GPIO_PORTF_BASE,IntGPIOF); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4); GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_FALLING_EDGE); GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_4); ROM_IntMasterEnable(); while(1) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0xE); } } void IntGPIOF(void) { volatile int ulLoop; GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_4); GPIO_PORTF_DATA_R |= LED_RED; for(ulLoop = 0; ulLoop < 900000; ulLoop++){ } // Delay for a bit. GPIO_PORTF_DATA_R = 0x00; GPIO_PORTF_DATA_R |= LED_GREEN; for(ulLoop = 0; ulLoop < 900000; ulLoop++){ } GPIO_PORTF_DATA_R = 0x00; GPIO_PORTF_DATA_R |= LED_BLUE; for(ulLoop = 0; ulLoop < 900000; ulLoop++){ } GPIO_PORTF_DATA_R = 0x00; }
  5. @ Your point is informative, thank you for that.
  6. Hi Lyon Thank you for your reply. I have made some modifications in the code. Now it is working fine. The link you mentioned was informative. int main(void) { char uartrecv; char stringrecv[]=""; int i=0; //SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Set the clocking to run directly from the external crystal/oscillator. // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the // crystal on your board. // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); inituart0(); UARTsendString("\r\nWELCOME"); UARTsendString("\r\nPlease, input a string: "); do { // Read a character using the blocking read function. This function // will not return until a character is available. uartrecv = UARTCharGet(UART0_BASE); stringrecv = uartrecv; i++; //Echo the character typed by the user UARTCharPut(UART0_BASE, uartrecv); // // Stay in the loop until either a CR or LF or i<10 is received. // } while((uartrecv != '\n') && (uartrecv != '\r') && (i<10)); UARTCharPut(UART0_BASE, '\n'); UARTsendString("\r\nYour string is: "); UARTsendString(stringrecv); UARTsendString("\r\nSee you next time."); return(0); } void UARTsendString(char *pt){ while(*pt!='\0'){ UARTCharPut(UART0_BASE, *pt); pt++; } }
  7. @@spirilis I agree with you but you can use hyperterminal to talk to the microcontroller by mentioning the ip address and the port of the microcontroller (via ethernet booster pack) in the hyperterminal configuration setting.
  8. Dear All, I want to collect the received characters from hyperterminal through UART0 of my launchapd and to save them to a string and then to print it back on the hyperterminal. When I try to print it (e.g. UARTCharPut(UART0_BASE, *stringrecv[0]) it prints nothing. my code is as follows; int main(void) { char uartrecv; char *stringrecv[4]; int i=0; //SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Set the clocking to run directly from the external crystal/oscillator. // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the // crystal on your board. // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); inituart0(); UARTsendString("\n\rWELCOME\n\r"); UARTsendString("Please, input a string: "); do { // // Read a character using the blocking read function. This function // will not return until a character is available. // uartrecv = UARTCharGet(UART0_BASE); *stringrecv = uartrecv; i=i+1; // // Write the same character using the blocking write function. This // function will not return until there was space in the FIFO and // the character is written. // //UARTCharPut(UART0_BASE, '\n'); //UARTCharPut(UART0_BASE, '\r'); UARTCharPut(UART0_BASE, uartrecv); // // Stay in the loop until either a CR or LF is received. // } while((uartrecv != '\n') && (uartrecv != '\r')); UARTCharPut(UART0_BASE, '\n'); UARTCharPut(UART0_BASE, '\r'); // // Put a character to show the end of the example. This will display on // the terminal. // UARTsendString("Your string is: "); //UARTsendString(*stringrecv); UARTCharPut(UART0_BASE, *stringrecv[0]); UARTCharPut(UART0_BASE, *stringrecv[1]); UARTCharPut(UART0_BASE, *stringrecv[2]); UARTsendString("\n\rSee you next time.\n\r"); // // Return no errors // return(0); } It prints correctly all the data i send to the hyperterminal except the data i store in the pointer *stringrecv. Is there something wrong with saving the characters to the string or retrieving back from the string ? Any suggestion is welcome. Regards, Iftikhar
  9. Dear All, I am interested to play with any Ethernet booster pack with my LM4F120 launchpad, I want to communicate with my launchpad via Ethernet using Hypertermincal. I have not so far bought any Ethernet booster pack but the one mentioned above seems to be a good candidate. Is there any one who could share the required library for interfacing WIZnet's W5200 controller with LM4F120 and to make the communication via Hyperterminal. ? Also I dont know what is the communication protocol on Hyperterminal via Ethernet, UDP or TCP/IP ? Thank you all in advance.
×