You are here

CYWUSB6934 | Cypress Semiconductor

CYWUSB6934

Summary: 17 Replies, Latest post by nguyen huy tien on 04 Dec 2009 12:29 PM PST
Verified Answers: 0
Last post
Log in to post new comments.
bassvdo's picture
User
1 post

Hi everybody, I'm trying to get a wireless connection between two atmel644p controllers with the cywusb6934 modules. I can acces the modules without any problems, but there just doesn't seem to be a wireless connection. Anyone a suggestion??

TX code:
#define F_CPU 8000000UL
#define F_OSC 8000000 // for ds18x20 & onewire

#include
#include
#include
#include
#include
#include
#include
#include
#include "CYWUSB693x.h"

//#define CYWM_CTRL_DIR_PORTB DDRB // Set bits here to 1 to make them outputs, 0 for inputs
//#define CYWM_CTRL_IN_PORTC PINC
//#define CYWM_CTRL_OUT_PORT PORTC

//pinset for 644p
#define CYWM_SCK PB7 // Output
#define CYWM_MISO PB6 // Input
#define CYWM_MOSI PB5 // Output
#define CYWM_nSS PB4 // Output

#define CYWM_nPD PD4 // Output
#define CYWM_nRESET PD3 // Output
#define CYWM_IRQ PD2 // Input

#define LED_PIN PA0 // Output led on tx

#define low(port, pin) (port &= ~_BV(pin))
#define high(port, pin) (port |= _BV(pin))

void SPI_Write(uint8_t byte)
{
SPDR = byte; // Send SPI byte
while(!(SPSR & (1<}

void CYWM_WriteReg(uint8_t which, uint8_t data)
{
low(PORTB, CYWM_nSS);
SPI_Write(REG_WRITE | which);
SPI_Write(data);
high(PORTB, CYWM_nSS);
}

uint8_t CYWM_ReadReg(uint8_t which)
{
low(PORTB, CYWM_nSS);
SPI_Write(which);
SPI_Write(which);
high(PORTB, CYWM_nSS);
return SPDR;
}

void wireless_putc(char data)
{
// Transmit data
_delay_us(10);
while (!((CYWM_ReadReg( REG_TX_INT_STAT ) & 0x01)));

//CYWM_WriteReg( REG_TX_INT_EN, 0x01 ); // Enable EMPTY interrupt

CYWM_WriteReg( REG_TX_DATA, data);

}

int main() {
uint8_t data, n;

cli(); // Disable interrupts

// Set port I/O directions
DDRB = (1< DDRD = (1< DDRA = 0x01; //led output

// Setup SPI
SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0); // _BV(SPIE)
//SPSR = _BV(SPI2X); // Fast SPI

// Setup interrupts
EICRA = (1< //GICR = _BV(INT0); // Enable INT0

// Set initial pin states
high(PORTB, CYWM_nSS);

for (n=0; n<5; n++) {
high(PORTA, LED_PIN);
_delay_ms(30);
low(PORTA, LED_PIN);
_delay_ms(30);
}

//sei(); // Enable interrupts

// Enable radio
high(PORTD, CYWM_nPD);
high(PORTD, CYWM_nRESET);

// Setup radio
// Test
data = CYWM_ReadReg( REG_ID );
if (data == 0x07) {

}
else {

}

CYWM_WriteReg( REG_CLOCK_MANUAL, 0x41 ); // Must be written with 0x41 after reset for correct operation
CYWM_WriteReg( REG_CLOCK_ENABLE, 0x41 ); // Must be written with 0x41 after reset for correct operation
CYWM_WriteReg( REG_SERDES_CTL, 0x03 | 0x08 ); // Enable SERDES
CYWM_WriteReg( REG_TX_VALID, 0xFF ); // Set all SERDES bits valid for TX
CYWM_WriteReg( REG_VCO_CAL, 0xC0 ); // Set VCO adjust to -5/+5
CYWM_WriteReg( REG_ANALOG_CTL, 0x04 ); // Enable PA Control Output
//CYWM_WriteReg( REG_PWR_CTL, 0x80 ); // Conserve power (must set REG_ANALOG_CTL, bit 6=1 to enable writes)
CYWM_WriteReg( REG_CHANNEL, 42 ); // Use channel 42
CYWM_WriteReg( REG_PA, 0x07 ); // Set maximum transmit power
//CYWM_WriteReg( REG_RX_INT_EN, 0x03 ); // Enable EOF and FULL interrupts for channel A
CYWM_WriteReg( REG_TX_INT_EN, 0x01 ); // Enable EMPTY interrupt
//CYWM_WriteReg( REG_CONTROL, 0x80 ); // Enable RX
CYWM_WriteReg( REG_CONTROL, 0x50 ); // Enable TX

// Repeat indefinitely
for

{
_delay_ms(150);

low(PORTA, LED_PIN);
_delay_ms(150);

wireless_putc(0x13);

// Echo received characters
//data = usart_getc();
//usart_putc(data);
//CYWM_WriteReg( REG_TX_INT_EN, 0x03 ); // Enable EMPTY interrupt

if ( CYWM_ReadReg(REG_TX_DATA ) ==0x13)
high(PORTA, LED_PIN);

}
return 0;
}

RX code:
#define F_CPU 8000000UL

#include
#include
#include
#include
#include
#include
#include
#include "CYWUSB693x.h"

//#define CYWM_CTRL_DIR_PORTB DDRB // Set bits here to 1 to make them outputs, 0 for inputs
//#define CYWM_CTRL_IN_PORTC PINC
//#define CYWM_CTRL_OUT_PORT PORTC

//pinset for 644p
#define CYWM_SCK PB7 // Output
#define CYWM_MISO PB6 // Input
#define CYWM_MOSI PB5 // Output
#define CYWM_nSS PB4 // Output

#define CYWM_nPD PD4 // Output
#define CYWM_nRESET PD3 // Output
#define CYWM_IRQ PD2 // Input

#define LED_PIN PA0 // Output led on rx

#define low(port, pin) (port &= ~_BV(pin))
#define high(port, pin) (port |= _BV(pin))

/*
ISR(INT0_vect) {
// Handle CYWUSB6934x interrupts
}
*/

void SPI_Write(uint8_t byte)
{
SPDR = byte; // Send SPI byte
while(!(SPSR & (1<}

void CYWM_WriteReg(uint8_t which, uint8_t data)
{
low(PORTB, CYWM_nSS);
SPI_Write(REG_WRITE | which);
SPI_Write(data);
high(PORTB, CYWM_nSS);
}

uint8_t CYWM_ReadReg(uint8_t which)
{
low(PORTB, CYWM_nSS);
SPI_Write(which);
SPI_Write(which);
high(PORTB, CYWM_nSS);
return SPDR;
}

int main() {
uint8_t data, n;

cli(); //disable all interrupts

// Set port I/O directions
DDRB = (1< DDRD = (1< DDRA = 0x01; //led output

if(DDRD == 0x18)
high(PORTA, LED_PIN);

// Setup SPI
SPCR = (1< //SPSR = _BV(SPI2X); // Fast SPI

// Setup interrupts
//EICRA = (1< //GICR = _BV(INT0); // Enable INT0

// Set initial pin states
high(PORTB, CYWM_nSS);

for (n=0; n<5; n++) {
high(PORTA, LED_PIN);
_delay_ms(30);
low(PORTA, LED_PIN);
_delay_ms(30);
}

//sei(); //enable all interrupts

// Enable radio
high(PORTD, CYWM_nPD);
high(PORTD, CYWM_nRESET);

// Setup radio
// Test
data = CYWM_ReadReg( REG_ID );
if (data == 0x07) {

}
else {

}

CYWM_WriteReg( REG_CLOCK_MANUAL, 0x41 ); // Must be written with 0x41 after reset for correct operation
CYWM_WriteReg( REG_CLOCK_ENABLE, 0x41 ); // Must be written with 0x41 after reset for correct operation
CYWM_WriteReg( REG_SERDES_CTL, 0x03 | 0x08 ); // Enable SERDES
CYWM_WriteReg( REG_TX_VALID, 0xFF ); // Set all SERDES bits valid for TX
CYWM_WriteReg( REG_VCO_CAL, 0xC0 ); // Set VCO adjust to -5/+5
CYWM_WriteReg( REG_ANALOG_CTL, 0x04 ); // Enable PA Control Output
//CYWM_WriteReg( REG_PWR_CTL, 0x80 ); // Conserve power (must set REG_ANALOG_CTL, bit 6=1 to enable writes)
CYWM_WriteReg( REG_CHANNEL, 42 ); // Use channel 42
CYWM_WriteReg( REG_PA, 0x07 ); // Set maximum transmit power
CYWM_WriteReg( REG_RX_INT_EN, 0x03 ); // Enable EOF and FULL interrupts for channel A
CYWM_WriteReg( REG_CONTROL, 0x90 ); // Enable RX
//CYWM_WriteReg( REG_CONTROL, 0x40 ); // Enable TX

// Repeat indefinitely
for (;

{
_delay_ms(100);
data = CYWM_ReadReg( REG_RX_INT_STAT );
if (data & 0x01 || data & 0x02) { // FULL A || EOF A
high(PORTA, LED_PIN);
CYWM_WriteReg( REG_RX_INT_EN, 0x03 ); // Enable EOF and FULL interrupts for channel A
if (data & 0x08) { // Valid A
data = CYWM_ReadReg( REG_RX_DATA_A );
//if(data== 0x13)
//high(PORTA, LED_PIN);
}
//data = CYWM_ReadReg( REG_RX_VALID_A );
//low(PORTA, LED_PIN);
}

// Echo received characters
//data = usart_getc();

}

return 0;
}

 

tge96's picture
User
7 posts

you might want to separate radio IC initialization and your functions transferring data.

here's one such example:

CYWM6934/CYWM6935 RF Module Code Snippets

nguyen huy tien's picture
User
12 posts

if i don't initial for CYWM6934,could i use to tranmist data ?

tge96's picture
User
7 posts

No, by default:

* SERDES isn't enabled, see REG_SERDES_CTL default

* REG_TX_VALID defaults to 00h meaning to transmit preamble bits instead of your data bits

* various clocks aren't setup properly by default, etc.

nguyen huy tien's picture
User
12 posts

can you introduce steps to interface with this module ?i am needing it for my graduation project.thanks!

nguyen huy tien's picture
User
12 posts

i don't find any document talk interface with mudule this,can you help me?

nguyen huy tien's picture
User
12 posts

thanks you very much.hihi,i from VietNam so i write English quiet poor.padon me.

nguyen huy tien's picture
User
12 posts

in R/W mode(burts) of module cyw6934 is what length of burst is defined (byte1+N) N? has it got 3bit EOF ?

nguyen huy tien's picture
User
12 posts

everybody help me? the bits EOF of register REG_SERDES_CTL ,what is it fuctions.i read but not understand?

tge96's picture
User
7 posts

for starters, and when your higher level firmware layer (protocol, etc) does not include some form of error correction, choose EOF=0, event will occur at the first invalid bit after a valid reception.

EOF fields allow you to define the condition for terminating a transaction on the receiver.

nguyen huy tien's picture
User
12 posts

thank you.i apoligize for this trouble because i am beginner so have many questions?

Log in to post new comments.