EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Replies /  Hi, this is what I m doing

 Hi, this is what I m doing

|

Microcontroller › AVR › How to interface fingerprint module serially with AVR ›  Hi, this is what I m doing

April 26, 2011 at 9:47 am #6035
usman
Participant

 

Hi, this is what I m doing but unsuccessful…  :-(
 
#define USART_BAUDRATE 57600
#define F_CPU 8000000
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16))) – 1)
 
 
//this is the packet i want to transmit. I have define the array as:
char GenImg[12] = { 0xEF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x03, 0x01, 0x00, 0x05 };
 
 
//I have called in the main these functions:
usart_init();
_delay_ms(500);
_delay_ms(500);
send_bytes(GenImg,12);
 
 
//this function is for “initialization of usart”:
void usart_init()
{
 
UCSRB |= (1 << RXEN) | (1 << TXEN);   // Turn on the transmission and reception circuitry
UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1); 
// Use 8-bit character sizes
UCSRC &= ~(1 << UMSEL); // In UCSRC, UMSEL = 0 for asynchronous
UCSRC &= ~(1<<USBS); //In UCSRC, USBS = 0 => 1 stop bit
 
UBRRL = BAUD_PRESCALE; 
// Load lower 8-bits of the baud rate value into the low byte of the UBRR register
UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value..
// into the high byte of the UBRR register
}
 
 
//this is function for transmitting:
void send_bytes(char *s, int length)
{
while (length–)
{
usart_transmit(*s);
s++;
}
}
 
 
void usart_transmit(unsigned char c)
{
while(!(UCSRA & (1 << UDRE))); // wait until UDR ready
UDR = c; // send character
}
 
 
Please help me to correct any errors!

RSS Recent Posts

  • Diameter of breadboard holes incompatible with size of components pins and jumper wires etc. August 16, 2022
  • Bose SoundTouch 20 - IC identification August 15, 2022
  • Digital Display Information August 15, 2022
  • 6V to 5.2V linear voltage regulator August 15, 2022
  • Nokia 5110 HW in Oshonsoft August 15, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools