Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Saving text data in *.txt file on sd card picaxe 20x2 microcontroler

Bartosz Wypych

New Member
Hello everyone!

Last time I try to solve my microcontroller picaxe 20x2 for additional text data in the *. txt file on SD set via SD card module in an alternative way:
Dubious link deleted - moderator

I have everything soldered and connected. On the program with detailed products pins for this module in Basic, but my code does not work.
I do not know how to change my program to solve the problem, I may misdefine the ports. navigation very important for help and advice.

I am sending my code, which has changed below:

Code:
' Pin configuration and SPI interface
symbol SD_CS_PIN = C. 2' Pin CS (Chip Select) SD Card
symbol MOSI_PIN = C. 0 ' PIN MOSI (Master Out Slave In)
MISO_PIN symbol = C. 7' PIN MISO (Master In Slave Out)
symbol SCK_PIN = C. 5' Pin SCK (serial clock)


results from the given m8
' Configure pins for SD cards

high SD_CS_PIN 'setting the CS pin to high state (SD card inactive)
serout SCK_PIN, N2400_8, ($FF) ' Sending byte to use SPI interface

' Function to initialize SD cards
initSD:
low SD_CS_PIN' SD card activation
serout SCK_PIN, N2400_8, (40$, 0, 0, 0, 0, 0, 0, 95$) ' Initialization Command
pause 100' Wait for initialization
High SD_CS_PIN' SD Card Deactivation
back
gosub initSD

Function of extra text to file on SD demand
save to SD:
low SD_CS_PIN' SD card activation
serout SCK_PIN, N2400_8, ($41, 0, 0, 0, 0, $95) ' Write command
Pause 100' Wait for SD cards to be ready
serout SCK_PIN, N2400_8, ("Hello, World!") ' Sample text to write
High SD_CS_PIN' Deactivate SD Cards
back
gosub save to SD
Main Program
Main:
call initSD ' Initialize SD cards

' Here you get the code that was uploaded before saving the file

saveToSD ' Save to description SD
 
Last edited by a moderator:
If you want to use the SD card so it can be read from a PC etc., you have to use the correct filesystem - the card is formatted with a file directory and sector or cluster allocation system.

All access to the SD card must be done via functions that understand the type of format and store data to comply with it.

Writing "raw" data will either do nothing or corrupt the card.

This is a filesystem library you could use:

Or another example:
 
I also suggest checking your SD card and SD card adapter separately. If you have an arduino, you cancross-check with the built-in SD example to verify if your SD card is functioning.
 
Thank you for your all replies but I have Picaxe microcontroller this is not blank pic or arduino or blank Atmega. It's programming in Basic in Picaxe programming editor and I don't know how to change my code to work correctly.
 
There is a picaxe project here that logs data to an SD card:

 

Latest threads

New Articles From Microcontroller Tips

Back
Top