Home arrow Forum
FreakLabs Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Chibi on Raven USB stick. (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Chibi on Raven USB stick.
#1672
Tim (Visitor)
Click here to see the profile of this user
Birthdate:
Chibi on Raven USB stick. 7 Months ago  
I remeber at some post you mentioned that chibi would be able to run on Raven USB Stick. In the past couple of days, I was trying to make that happen. However, it doesn't seem working. Here's briefly what I did:

Use the chibi v1.1 (unzipped as 2010_01_17xxx). Compiling with the following parameters:

(1) mcu at90usb1286
(2) radio at86rf230
(3) F_CPU 8000000 (8MHz)
(4) target hex

the compiling/linking went smooth, and I get chibi_demo.hex file of ~11k generated, I can use JTAG ice mkII to load onto my Raven USB Stick. However, the USB stick doesn't seems functioning, I observe the following:

(1) There's no LED flashing at all.
(2) The system (WinXP) doesn't prompt me for USB driver when I plug it in.
(3) After a little while, the system prompts me that there's a USB hardware found, but not recognized, it then been put into the registry as a "Unkown device" under USB category in "Device Manager".

I tried to use the windows device manager to force a "update driver", and I navigate to use your freakUSB_CDC.inf driver, but it says "doesn't contain information for the hardware".

Have you encouter this before?
Some more facts on my side:
(1) This is a brand new stick that I just received couple of days ago. The default Raven wireless demo program works fine on the stick (it works both on coordinator mode and sniffer mode)
(2) the at90usb1287 still works. Use JTAG Ice mkII, I can browse the fuse setting and read signature etc without a problem. It shows the uC works at 8MHz - it is not bricked.
(3) I notice that the uC from my Raven USB is a at90usb1287, instead of at90usb1286 (which is used in Chibi), could this be a problem?

Hope these can help you pinpoint the problem in my env.

Thanks for you great work on Chibi!

-Tim
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
  Reply Quote
#1673
Akiba (Admin)
Admin
Posts: 959
graph
User Online Now Click here to see the profile of this user
Re:Chibi on Raven USB stick. 7 Months ago Karma: 15  
Yeah, for the Raven platform, the IRQ, RESET, and SLP_TR pins are different. You'll have to change these in the chb_drvr.h header file in order to get it working. Otherwise, I can try it out later, but I can't guarantee a time frame right now. Also need to dig up my old Ravens.

The software checks that the state machine registers are in the correct state. If not, then it will just sit in a loop. That's why the USB won't get recognized. It's more of a way to indicate explicitly that something is wrong with the setup of the software rather than to just silently fail. Not everyone is using the print statements which is why I did it that way. Once the IO, IRQ, and interrupt vectors are setup properly, then it should get recognized and work out of the box.
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
 
Last Edit: 2010/02/03 21:39 By cjwang.
  Reply Quote
#1674
Tim (Visitor)
Click here to see the profile of this user
Birthdate:
Re:Chibi on Raven USB stick. 7 Months ago  
Yeah, thanks for insightful comments.

But, even that the SLP, RESET, etc all wrongly connected with the rf230, would the at90usb1287 still should be working? I mean, no matter how wrong the uC and rf230 connected, would the usb side still working? If so, it seems odd to me that the PC doesn't recognize the usb stick. If the problem only reside in connection between uC an radio, I would expect to see the serial console and it failed to send message out or something like that.

Forgive my naive questions, I have couple of year AVR experience, but for PC to AVR thru USB, I only use the FTDI thru UART instead of the avr-CDC, so, I guess might messed something there.

How do you think?

-Tim
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
  Reply Quote
#1675
Tim (Visitor)
Click here to see the profile of this user
Birthdate:
Re:Chibi on Raven USB stick. 7 Months ago  
Sorry Akiba, for shooting my question without finish second half of your reply.

If that's the case, then, I will check back my code and get those PINs corrected.

I will keep you updated!

-Tim
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
  Reply Quote
#1676
Akiba (Admin)
Admin
Posts: 959
graph
User Online Now Click here to see the profile of this user
Re:Chibi on Raven USB stick. 7 Months ago Karma: 15  
Incidentally, keep an eye on chb_radio_init() in the chb_drvr.c file. The last line is:

Code:

while (chb_get_state() != RX_AACK_ON);
That's where the hang will occur if anything is wrong with the platform port. If you see it stuck there, then you'll need to check the init to make sure that the registers are getting set properly. For the Raven, since its using essentially the same chips, it will just be a matter of checking that the IO and IRQ pin/vector are correctly set.
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
  Reply Quote
#1677
Tim (Visitor)
Click here to see the profile of this user
Birthdate:
Re:Chibi on Raven USB stick. 7 Months ago  
Thanks,

Here's what I got

in Chb_drvr.h
************************************
#define CHB_RSTPORT PORTB
#define CHB_RSTPIN 4
#define CHB_SLPTRPORT PORTB
#define CHB_SLPTRPIN 5
#define CHB_DDR_SLPTR DDRB
#define CHB_DDR_RST DDRB
#define CHB_RADIO_IRQ INT4_vect
************************************

whereas in Raven USB stick, based on http://www.atmel.com/dyn/resources/prod_documents/doc8117.pdf

RSTPORT -> PB5
SLPTR -> PB4
RADIO_IRQ -> PD4

I am make the change in driver accordingly. By the way, CHB_RADIO_IRQ PD4? I checked the at90usb1287 datasheet, it doesn't seem PD4 had a interrupt. It seems more like PE4 (INT4).

Any comments?

I will give the above change a quick try anyways, and then, got go sleep (I am in EST US time zone)

I will keep you updated!

-Tim
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
  Reply Quote
#1678
Akiba (Admin)
Admin
Posts: 959
graph
User Online Now Click here to see the profile of this user
Re:Chibi on Raven USB stick. 7 Months ago Karma: 15  
Crap, I forgot about that. The Raven USB sticks have a weird connection to the radio. The IRQ is connected to an timer capture input. You need to use a timer capture interrupt vector which will trigger on each rising edge. You normally would use this to increment some internal counter to count events or frequency, but you can also use it to interrupt after each count. It's kind of hack but this is what had to be done in the FreakZ stack.
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
 
Last Edit: 2010/02/03 23:07 By cjwang.
  Reply Quote
#1679
Tim Ren (User)
Apprentice Freak
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
Re:Chibi on Raven USB stick. 7 Months ago Karma: 0  
IT works.

Here's the change:

************************************
#define CHB_RSTPORT PORTB
#define CHB_RSTPIN 5
#define CHB_SLPTRPORT PORTB
#define CHB_SLPTRPIN 4
#define CHB_DDR_SLPTR DDRB
#define CHB_DDR_RST DDRB
#define CHB_RADIO_IRQ INT4_vect
************************************

If you diff it, the only thing change is flip the 5 and 4. And that's it.

I haven't done extensive testing, but, this change made chibi works on Raven USB STick.

Cheers!

-Tim
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
 
Last Edit: 2010/02/04 09:18 By rentg.
  Reply Quote
#1680
Akiba (Admin)
Admin
Posts: 959
graph
User Online Now Click here to see the profile of this user
Re:Chibi on Raven USB stick. 7 Months ago Karma: 15  
I suspect you're going to need to mod the IRQ vector as well to receive data. But glad to hear the rest is working
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
  Reply Quote
#1682
Tim Ren (User)
Apprentice Freak
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
Re:Chibi on Raven USB stick. 7 Months ago Karma: 0  
You are right Akiba, as I checked this morning, receiving was not working right.

I checked the Raven USB code base and find this file: board_rzusbstick.h.

I think this one serves as the chb_drvr.h in chibi. It defines the port/pin connections, et al.

Here's the RF230 section:


QUOTE:
/* RF230 Section. */



#define SLP_TR (0x04) //!< Pin number that corresponds to the SLP_TR line.
#define DDR_SLP_TR (DDRB) //!< Data Direction Register associated with the SLP_TR pin.
#define PORT_SLP_TR (PORTB) //!< Port Register associated with the SLP_TR pin.
#define PIN_SLP_TR (PINB) //!< Pin Register associated with the SLP_TR pin.

#define RST (0x05) //!< Pin number that corresponds to the RST line.
#define DDR_RST (DDRB) //!< Data Direction Register associated with the RST pin.
#define PORT_RST (PORTB) //!< Port Register associated with the RST pin.
#define PIN_RST (PINB) //!< Pin Register associated with the RST pin.

#define TST (0x06) //!< Pin number that corresponds to the TST line.
#define DDR_TST (DDRB) //!< Data Direction Register associated with the TST pin.
#define PORT_TST (PORTB) //!< Port Register associated with the TST pin.
#define PIN_TST (PINB) //!< Pin Register associated with the TST pin.

#define RF230_PORT_SPI (PORTB) //!< Port Register associated with the SPI module.
#define RF230_DDR_SPI (DDRB) //!< Data Direction Register associated with the SPI module.

#define RF230_DD_SS (0x00)
#define RF230_DD_SCK (0x01)
#define RF230_DD_MOSI (0x02)
#define RF230_DD_MISO (0x03)

#define RF230_SPI_PRR (PRR0) //!< Power reduction register associated with the RF230 radio transceiver.
#define RF230_SPI_PRR_BIT (PRSPI) //!< Bit in the PRR associated with the RF230 radio transceiver.

#define RF230_SPI_DATA_REG (SPDR) //!< SPI Data Register.
#define RF230_SPI_CTRL_REG (SPCR) //!< SPI Control Register.
#define RF230_SPI_SPE (SPE) //!< SPI Enable.
#define RF230_SPI_MSTR (MSTR) //!< SPI Enable Master Mode.
#define RF230_SPI_2X (SPI2X) //!< SPI Double Speed.
#define RF230_SPI_STATUS_REG (SPSR) //!< SPI Status Register.
#define RF230_SPI_DONE_FLAG (SPIF) //!< Bit in SPSR that indicates that the SPI transmission is done.

#define RF230_INTERRUPT_ENABLE() (TIMSK1 |= (1 << ICIE1)) //!< Macro that enables the interrupt in the module where the IRQ pin from the radio transceiver is connected.
#define RF230_INTERRUPT_DISABLE() (TIMSK1 &= ~(1 << ICIE1)) //!< Macro that disables the interrupt in the module where the IRQ pin from the radio transceiver is connected.

#define RF230_ACK_INTERRUPT_FLAG() (TIFR1 |= (ICIE1)) //!< Macro that is used to clear the interrupt flag when fired.


And truly as you described above, it uses some timer mechanism function as IRQ interrupt in at90usb1287 (last 3 lines of code). But, how should I port it into chibi?

-Tim
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
 
Last Edit: 2010/02/04 09:22 By rentg.
  Reply Quote
#1683
Tim Ren (User)
Apprentice Freak
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
Re:Chibi on Raven USB stick. 7 Months ago Karma: 0  
All right, I guess the original code should be modified like this:


QUOTE:
#define CHB_RSTPORT PORTB
#define CHB_RSTPIN 5
#define CHB_SLPTRPORT PORTB
#define CHB_SLPTRPIN 4
#define CHB_DDR_SLPTR DDRB
#define CHB_DDR_RST DDRB
#define CHB_RADIO_IRQ TIMER1_CAPT_vect


Then, in the chibi driver c file:

ISR(INT4_vect) will change to ISR(TIMER1_CAPT_vect)

And, seems I need to add in clear flag call into the end of ISR() routine:

QUOTE:
#define RF230_ACK_INTERRUPT_FLAG() (TIFR1 |= (ICIE1)) //!< Macro that is used to clear the interrupt flag when fired.


However, as I dig more into the Atmel's RavenUSBSTick code base, it seems more complicated than your code - I'd agree that they implement this in a very weird way.

-Tim
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
 
Last Edit: 2010/02/05 13:47 By rentg.
  Reply Quote
#1695
Akiba (Admin)
Admin
Posts: 959
graph
User Online Now Click here to see the profile of this user
Re:Chibi on Raven USB stick. 6 Months, 4 Weeks ago Karma: 15  
Yes, actually I just dug out my old Ravens and did the mods. They're tested and working. You can check your port against what I did, but basically, you seem to have everything correct.

Here's the file:
File Attachment:
File Name: chb_drvr.h
File Size: 11111
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
  Reply Quote
#1696
Tim Ren (User)
Apprentice Freak
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
Re:Chibi on Raven USB stick. 6 Months, 4 Weeks ago Karma: 0  
Thanks Akiba!

Just let you know, after your modification and add in a call of CFG_CHB_INTP_RISE_EDGE() in chb_drvr.c (radio_init() function), chibi works like charm on my Raven USB Stick. It is excellent!

Cheers! Now, I am waiting for another 3 Raven usb stick from digi.

-Tim
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
  Reply Quote
#1698
Akiba (Admin)
Admin
Posts: 959
graph
User Online Now Click here to see the profile of this user
Re:Chibi on Raven USB stick. 6 Months, 4 Weeks ago Karma: 15  
Whoops...forgot that the CHB_INT_RISE_EDGE() macro isn't released yet. It'll be part of the next release. Got the suggestion from Silicon Farmer to include all the platform specific config in the header file.

Sorry about that, but glad it's working
Enter code here   
Please note, although no boardcode and smiley buttons are shown, they are still useable
 
Report to moderator   Logged Logged  
  Reply Quote
Go to top Post Reply
get the latest posts directly to your desktop