Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Bobi's Content

There have been 10 items by Bobi (Search limited from 27-April 23)


By content type

See this member's

Sort by                Order  

#20603 FreeRTOS handling hardware interrupts

Posted by Bobi on 14 November 2011 - 10:16 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi, I found the problem!!! It works great now.
There are a few things which need to be done:
  • In the documentation of the AT91F_AIC_ConfigureIt function the first parameter is described as "pointer to the AIC registers" and therefore when you configure your interrupt you should pass AT91C_BASE_AIC but not AT91C_BASE_PIOA. I'm not absolutely sure why is that but it just works only if I pass the AT91C_BASE_AIC register. You do the same for the AT91F_AIC_EnableIt call. The activation level that works for me is AT91C_AIC_SRCTYPE_EXT_LOW_LEVEL - (AIC) External Sources Code Label Low-level Sensitive.
  • If you are using IAR you have to do a few more steps. You need to decide whether your interrupt service routine should cause a context switch. Look here for an example.

In my case - I needed a context switch, so I had to create a DriverISR.s79 assembler file where I execute
portSAVE_CONTEXT
call the ISR routine
portRESTORE_CONTEXT

And this is all FreeRTOS specific (this is also described in the demo from the link above).

Best Regards,
Bobi



#20451 FreeRTOS handling hardware interrupts

Posted by Bobi on 10 November 2011 - 02:27 PM in Netduino Plus 2 (and Netduino Plus 1)

Well, it's kind of impossible to troubleshoot interrupt issues remotely ;-) I am not very familiar with FreeRTOS itself, but according to the information I've found on the Internet, it requires some special coding for ISR routines, like declaring __attribute__((interrupt("IRQ"))) (?) and portENTER_CRITICAL()/portEXIT_CRITICAL() macros (?) - so I would suggest you looking at the FreeRTOS documentation and samples.


No, the register contains bit mask, so you'd need to use 1 << 29; usually the code looks like

...
isr = AT91C_BASE_PIOA->PIO_ISR;
if(isr & SW1)
{
  // Button
}
...
AT91C_BASE_AIC->AIC_EOICR = 0; // Clear AIC to complete ISR processing


Hi, thanks for your replies!
I already have a working demo of the same functionality which was included in the Getting Started Tutorial I got from Atmel. It works perfectly fine and the code looks like executing exactly the same steps except that they are using a different port. FreeRTOS have implemented their own port and one solution I can think of is to get FreeRTOS running with the Atmel port for sam7x512.



#20424 FreeRTOS handling hardware interrupts

Posted by Bobi on 09 November 2011 - 06:54 PM in Netduino Plus 2 (and Netduino Plus 1)

static void prvSetupHardware( void )
{
  ...
  // The second parameter should be button pin               		
  AT91F_PIO_InterruptEnable(AT91C_BASE_PIOA, SW1);
  ...        
}
Also, don't forget to read PIO_ISR in Handler().


OK, I did this and now when I deploy the bin file on the Netduino and connect it in my Computer I see an instant flash and the LED stays ON and when you press the button nothing happens. There must be something else... ?

How is the right way to read the PIO_ISR register? Should I simply say:
   if(PIO_ISR  == 29){
      // ...
   }



#20418 FreeRTOS handling hardware interrupts

Posted by Bobi on 09 November 2011 - 04:59 PM in Netduino Plus 2 (and Netduino Plus 1)

In the above code, there is missing call to enable clock on PIOA (i.e. AT91F_PMC_EnablePeriphClock) and AT91F_PIO_InterruptEnable() for the button. Also, you should use constants instead of hardcoded values in AT91F_AIC_ConfigureIt(), like PIO_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE.

Hi,

Thanks for the fast reply! It looks perfectly fine to me now but it still doesn't work. What am I misssing?

#define PIO_INTERRUPT_LEVEL 0x7
#define AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE ((unsigned int) 0x1 <<  5)

void Handler(void)
{
        AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, LED1 ); // turn LED OFF				
}

static void prvSetupHardware( void )
{
	AT91F_PIO_CfgOutput( AT91C_BASE_PIOB, LED1 );        
        AT91F_PIO_SetOutput( AT91C_BASE_PIOB, LED1 );	// turn LED ON              
	
	AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA );
	AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << AT91C_ID_PIOB ) ;
	                        
        AT91F_PIO_InterruptEnable(AT91C_BASE_PIOA, 1 << AT91C_ID_PIOA);
        
        AT91F_PIO_CfgInput( AT91C_BASE_PIOA, SW1 );
        AT91F_PIO_CfgPullup( AT91C_BASE_PIOA, SW1 );
        AT91F_PIO_CfgInputFilter( AT91C_BASE_PIOA, SW1 );
        
        AT91F_AIC_ConfigureIt(AT91C_BASE_PIOA, 
                              AT91C_ID_PIOA, 
                              PIO_INTERRUPT_LEVEL, 
                              AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE, 
                              Handler);
        AT91F_AIC_EnableIt(AT91C_BASE_PIOA, AT91C_ID_PIOA);        
}

I'm not aboslutely sure about the PIO_INTERRUPT_LEVEL value. In the documentation they say that its between 0(lowest) and 7(highest). Otherwise this is what you mean, right?



#20415 FreeRTOS handling hardware interrupts

Posted by Bobi on 09 November 2011 - 03:33 PM in Netduino Plus 2 (and Netduino Plus 1)

All I/O lines of the same port share one interrupt. In your trivial case, you could just simply check the appropriate bit of PIO_ISR register in the interrupt handler.


Hi,

Ok great and do you think that the interrupt initialization is OK then, because when I press the button nothing happens?
Is there any way to debug your code when it's running on the netduino if you don't have a jtag?



#20410 FreeRTOS handling hardware interrupts

Posted by Bobi on 09 November 2011 - 02:32 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello,

I want to run a FreeRTOS program on my Netduino plus board. I'm working on the ARM7 uIP demo for IAR (uIP_Demo_IAR_ARM7) that's provided with the FreeRTOS source code. I know that this may be an easy question but I have lost too much time trying to do it on my own. I want to be able to handle PIO button interrupts.
The netduino has an onaboard button (PA29) and I want to initialise and handle the interrupts so that when you press the button the onboard LED (PB23) will turn ON.
I want to achieve this using the provided FreeRTOS at91sam7x256 port. I already have it working with the demos which come from the Atmel site but they use a very different port which fails to work together with the FreeRTOS. I want to use the FreeRTOS port because the main goal of the application will be far different from turning LEDs on and off.

Here is my code:
First in board.h I have defined that LED1 is (1 << 23) and SW1 is (1 << 29).
I have the following interrupt handler, which will turn the onboard LED ON:

void Handler(void)
{
        if( AT91F_PIO_GetInput( AT91C_BASE_PIOA ) & LED1 )
        {
                AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED1 );
        }
        else
        {
                AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED1 );					
        }  
}

And in the prvSetupHardware function I have added the following:
        AT91F_PIO_CfgInput( AT91C_BASE_PIOA, SW1 );
        AT91F_PIO_CfgPullup( AT91C_BASE_PIOA, SW1 );
        AT91F_PIO_CfgInputFilter( AT91C_BASE_PIOA, SW1 );
        
        AT91F_AIC_ConfigureIt(AT91C_BASE_PIOA, AT91C_ID_PIOA, 0x07, 0x0, Handler);
        AT91F_AIC_EnableIt(AT91C_BASE_PIOA, AT91C_ID_PIOA);

And here I am confused about am I initializing the interrupt properly? As long as the button belongs to PA29 I know that I have to use the AT91C_BASE_PIOA when I make the call to AT91F_AIC_ConfigureIt. And here I am not sure about the irq_id parameter. Should it be 29 (as I am using PA29) or should it be AT91C_ID_PIOA? And if its AT91C_ID_PIOA where should I specify that I want to handle intterupts coming from PA29?

Thanks :)



#20362 FreeRTOS

Posted by Bobi on 08 November 2011 - 08:17 AM in Netduino Plus 2 (and Netduino Plus 1)

For entertainment, I tried FreeRTOS on the Netduino Plus using SAM-BA. The networking has flakes, but it is working. With the SAM7X demo, it acts like a USB mouse OK, prints stats via the web server, and gives control of the LED to a web page. It is easy to get the real Netduino Plus software back into it when you are done.

Anybody else playing about with this, or something similar?


This sounds awesome! Could you make available some code samples or anything else... about how is it possible to handle button interrupts. For the last many days I've been trying to create a simple freeRTOS program where I have one blinking LED and when you press the onboard button I want to handle the interrupt and set the LED off.

What I've tried so far was to get the SAM7x512 Getting Started example from Atmel and their demo worked perfectly fine. Then I tried to do the same thing in one of the freeRTOS demos but it seems that the port is not the same and I don't know how to configure my interrupt correctly.



#19518 Keil

Posted by Bobi on 21 October 2011 - 11:10 AM in Netduino 2 (and Netduino 1)

Hi Chris, thanks a lot for your reply! I worked it out and it is awesome. I also tried the IAR environment and for the last couple of days I'm exploring one of the freeRTOS TCP/IP demos for AT91SAM7X. It creates a web server wich I maneged to get running on my netduino :) Now I'm trying to figure out how it works. It uses the uIP TCP/IP stack and the dosumentation is not very clear... I'll be glad if you or someone else could share some experience about the uIP stack. I want to hadle HTTP POST requests in the server application. It seems to work fine with the GET requests... I don't see what's the difference. When I send a POST request in Fiddler I can see that the server returns http status code 504. Thanks very much in advance!



#19405 Keil

Posted by Bobi on 19 October 2011 - 11:41 AM in Netduino 2 (and Netduino 1)

Then depower/repower and use Atmel SAM-BA to deploy your Keil-compiled code. You can use the Atmel SAM7X reference sample as a starting point.

Chris


Hi Chris,

Can you please provide some more information about how can I use Atmel SAM-BA to deploy my Keil-compiled code?

I have downloaded and istalled the latest SAM-BA version - 2.10 I've read the tutorial and some other internet resources but I even failed the SAM-BA start up screen where you have to select a usb device and the model of your target device. It fails to connect. I'm not sure if I enter the usb device correctly - \usb\Netduino. It complains that it has failed to open a connection.
My development computer is running 64bit Windows 7 and in the Devices Manager I saw that the usb device where my netduino is connected has the name "Netduino". On the atmel site I saw that their SAM-BA supports 64bit Win7 so that shouldn't be a problem.

Another question - isn't it possible to build my Keil-compiled code in a way that I can deploy it on the Netduino using the MFDeploy tool?

Thanks very much in advance!



#18579 .NET Micro Framework 4.2 RC2 released

Posted by Bobi on 29 September 2011 - 09:30 AM in General Discussion

You don't need a new Netduino SDK for 4.2 RC2, but we do have a new firmware build. Testing now...

Chris


Hi,
Has the new netduino firmware finally been released?




home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.