<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>MEL PICBASIC Forum - AI Tutorials and Guides</title>
		<link>https://www.picbasic.co.uk/forum/</link>
		<description><![CDATA[AI Tutorials and Guides — Using AI Effectively with PicBasic Pro
Step-by-step guides, prompt templates, and practical techniques for getting reliable, compilable code from AI tools. Community contributions welcome — share what works, share what doesn't.]]></description>
		<language>en</language>
		<lastBuildDate>Thu, 28 May 2026 09:22:30 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>https://www.picbasic.co.uk/forum/images/misc/rss.png</url>
			<title>MEL PICBASIC Forum - AI Tutorials and Guides</title>
			<link>https://www.picbasic.co.uk/forum/</link>
		</image>
		<item>
			<title>Tutorial 07 — System Prompts for Embedded Development: Getting Reliable Behaviour Fro</title>
			<link>https://www.picbasic.co.uk/forum/showthread.php/27129-Tutorial-07-—-System-Prompts-for-Embedded-Development-Getting-Reliable-Behaviour-Fro?goto=newpost</link>
			<pubDate>Thu, 28 May 2026 07:48:27 GMT</pubDate>
			<description>*Tutorial 07 — System Prompts for Embedded Development: Getting Reliable Behaviour From Any AI Tool* 
AI and PicBasic Pro Tutorial Series — Post 7...</description>
			<content:encoded><![CDATA[<div><b><font size="5">Tutorial 07 — System Prompts for Embedded Development: Getting Reliable Behaviour From Any AI Tool</font></b><br />
<i>AI and PicBasic Pro Tutorial Series — Post 7</i><br />
<i>Content produced with AI assistance and reviewed by the forum administrator.</i><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Problem This Tutorial Solves</font></b><br />
<br />
<br />
You ask an AI to add a single subroutine to your existing code. It returns the subroutine — plus a restructured main loop, renamed variables, reformatted comments, and three functions you did not ask for. Your working code is gone. The new version does not compile. You have lost more time than the task would have taken manually.<br />
<br />
<br />
This is not unusual. AI tools are trained to be helpful, and their definition of helpful often includes improving, expanding, and tidying things that were not in scope. For general software development this is sometimes useful. For embedded development it is consistently destructive.<br />
<br />
<br />
The fix is a system prompt — a set of instructions that runs before every conversation and overrides the AI's default behaviour. A well-written system prompt for embedded work tells the AI to do exactly what was asked, nothing more, ask before assuming, and never touch code it was not told to touch.<br />
<br />
<br />
This tutorial covers what a system prompt is, where it lives in the major AI tools, and provides a set of generic starting prompts that embedded developers can adapt for their own use.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What is a System Prompt?</font></b><br />
<br />
<br />
A system prompt is a permanent instruction that applies to every conversation before you type anything. It is not part of the conversation — it sits above it. The AI reads it at the start of every session and its instructions take priority over default behaviour.<br />
<br />
<br />
Different tools call this different things and put it in different places:<br />
<br />
<ul><li><b>Claude (claude.ai)</b> — Settings &gt; Profile &gt; &quot;What would you like Claude to know about you?&quot; — applies to all conversations. Additional instructions can be added per-workspace under the workspace instruction.</li>
<li><b>ChatGPT (chat.openai.com)</b> — Settings &gt; Personalisation &gt; Custom Instructions — two fields: what the AI should know about you, and how it should respond.</li>
<li><b>Copilot / GitHub Copilot</b> — Custom instructions via a <i>.github/copilot-instructions.md</i> file in the repository, or via the Copilot settings panel in supported IDEs.</li>
<li><b>Warp (terminal AI)</b> — Warp AI preferences and custom prompt settings in the Warp settings panel.</li>
<li><b>API-based tools</b> — the system parameter in the API call, which accepts a plain text instruction applied before every message.</li>
</ul><br />
<br />
The principle is the same regardless of tool. You write the instruction once and it applies everywhere within that tool. You do not repeat it in every conversation.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What Embedded Developers Need From a System Prompt</font></b><br />
<br />
<br />
The failure modes of AI tools on embedded development tasks are well-documented. The system prompt needs to address each one directly:<br />
<br />
<br />
<b>Scope creep</b> — the AI adds functionality that was not requested. Fix: require the AI to do exactly what was asked and nothing else.<br />
<br />
<br />
<b>Silent modification</b> — the AI restructures, renames, or reformats code that was not in scope. Fix: require explicit instruction before touching anything outside the stated task.<br />
<br />
<br />
<b>Deletion without permission</b> — the AI removes code it considers redundant or replaces working sections with its own version. Fix: prohibit deletion or replacement of existing code without explicit confirmation.<br />
<br />
<br />
<b>Assumption instead of clarification</b> — the AI fills in missing information with assumptions rather than asking. For embedded work this produces plausible-looking code with wrong register values or incorrect timing. Fix: require the AI to ask before proceeding when information is missing or ambiguous.<br />
<br />
<br />
<b>Confidence without basis</b> — the AI presents uncertain information as fact. Fix: require the AI to flag uncertainty explicitly rather than approximating silently.<br />
<br />
<br />
<b>Incomplete output</b> — the AI produces skeleton code or placeholder comments without telling you that is what it is doing. Fix: require complete, compilable output or an explicit statement that a skeleton is being produced.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Generic Embedded Development System Prompt</font></b><br />
<br />
<br />
The following prompt addresses all of the above failure modes. It is written to be tool-agnostic — it works in Claude, ChatGPT, Copilot, Warp, and any other AI tool that accepts a system-level instruction.<br />
<br />
<br />
<font color="#CC0000"><b>This is a starting point. Read every section, understand what it does, and adapt it before use. Do not paste it unchanged — the device and compiler placeholders must be replaced with your specific details.</b></font><br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">; ============================================================<br />
; EMBEDDED DEVELOPMENT SYSTEM PROMPT — GENERIC STARTING POINT<br />
; Adapt before use — replace all placeholders<br />
; ============================================================<br />
<br />
<br />
I am an embedded systems developer working in [YOUR LANGUAGE/COMPILER]<br />
targeting [YOUR DEVICE FAMILY]. I have [YOUR EXPERIENCE LEVEL] experience<br />
with this platform.<br />
<br />
<br />
SCOPE — MOST IMPORTANT<br />
Do exactly what I ask. Nothing more.<br />
Do not add features, functions, or improvements I did not request.<br />
Do not restructure, reformat, or rename anything outside the stated task.<br />
Do not expand the scope of the task without asking me first.<br />
If completing the task requires changing something outside the stated scope,<br />
tell me what needs to change and why — then wait for my confirmation.<br />
<br />
<br />
EXISTING CODE IS WORKING UNLESS I SAY OTHERWISE<br />
Treat all code I provide as working unless I explicitly tell you it has<br />
a problem. Do not correct, improve, or rewrite sections I did not ask<br />
you to change. Do not delete anything. Do not replace working code with<br />
your own version unless asked.<br />
<br />
<br />
If you believe existing code contains an error I have not mentioned,<br />
tell me once, clearly, and wait. Do not fix it silently.<br />
<br />
<br />
BEFORE YOU WRITE ANY CODE — ASK FIRST IF:<br />
- The target device is not specified or is ambiguous<br />
- The clock speed or oscillator configuration is not stated<br />
- The required register or peripheral behaviour is not clear<br />
- The task description could reasonably be interpreted in more than one way<br />
- Information needed to write correct code is missing<br />
<br />
<br />
Do not assume. Do not approximate. Ask the specific question, wait for<br />
the answer, then proceed.<br />
<br />
<br />
UNCERTAINTY<br />
If you are not certain about a syntax rule, register name, bit value,<br />
or timing calculation — say so explicitly before presenting any code.<br />
State what you are uncertain about and where to verify it.<br />
Do not present uncertain information as fact.<br />
<br />
<br />
CODE QUALITY<br />
Every code response must be complete and ready to compile.<br />
No skeleton code, no placeholder comments, no TODO sections — unless<br />
I explicitly ask for an outline.<br />
If the task cannot be completed without information you do not have,<br />
ask for that information rather than producing incomplete output.<br />
<br />
<br />
CHANGES TO EXISTING CODE<br />
When modifying code I have provided:<br />
- Show me the original unchanged first, clearly marked<br />
- Then show the modified version, clearly marked<br />
- Mark every individual change with a comment: ; CHANGED: reason<br />
- Do not silently restructure anything outside the changed lines<br />
<br />
<br />
CALCULATIONS<br />
Show all timing and frequency calculations explicitly:<br />
formula, values substituted, result.<br />
Mark approximate results as approximate and state the margin.<br />
Do not present a calculated result without showing the working.<br />
<br />
<br />
FORMAT<br />
Code in code blocks. Explanations in plain prose.<br />
Lead with the answer. No lengthy preamble.<br />
If you cannot do what I asked, say so in one sentence and explain why.</code><hr />
</div><br />
<hr /><br />
<br />
<br />
<b><font size="4">How to Adapt It</font></b><br />
<br />
<br />
<b>Replace the placeholders</b><br />
<br />
<br />
The first section contains three placeholders you must fill in:<br />
<br />
<ul><li><i>[YOUR LANGUAGE/COMPILER]</i> — for example: PicBasic Pro 3 by melabs, or MPLAB XC8, or assembly</li>
<li><i>[YOUR DEVICE FAMILY]</i> — for example: PIC16F mid-range, or PIC18F enhanced, or a specific part number</li>
<li><i>[YOUR EXPERIENCE LEVEL]</i> — this is worth including. &quot;I have 20 years experience with PIC hardware&quot; produces different output to &quot;I am learning embedded development&quot;. The AI calibrates its explanations accordingly.</li>
</ul><br />
<br />
<b>Add device-specific requirements</b><br />
<br />
<br />
If you work exclusively with one device family, add a section that states it. For PBP3 specifically, consider adding:<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">; ============================================================<br />
; PBP3-SPECIFIC ADDITIONS — ADD BELOW THE GENERIC PROMPT<br />
; ============================================================<br />
<br />
<br />
PICBASIC PRO 3 SPECIFIC<br />
All code is for PicBasic Pro 3 (PBP3) by melabs.<br />
DEFINE OSC must always appear before any timing-dependent code.<br />
CONFIG bits must match the target device datasheet exactly.<br />
Do not mix 16F and 18F CONFIG syntax.<br />
If using inline assembly, all variables used in ASM blocks must be<br />
declared BANK0 SYSTEM unless the code explicitly manages banking.<br />
Show all Timer period calculations using the formula:<br />
Period = (PR2 + 1) x 4 x Tosc x Prescaler</code><hr />
</div><br />
<font color="#CC0000"><b>NOTE: The PBP3-specific section above is an example. The Timer formula shown is for Timer2 on mid-range devices. Verify it against your device datasheet before using it as a reference.</b></font><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Clarification Requirement — The Most Valuable Instruction</font></b><br />
<br />
<br />
The single most valuable instruction in the prompt is the ask-first requirement. By default AI tools assume rather than ask. For general software development this speeds things up. For embedded development it produces code with wrong register values, incorrect clock assumptions, and timing errors that only surface on hardware.<br />
<br />
<br />
The instruction works because it changes the AI's default response to ambiguity. Instead of filling a gap with a plausible assumption, it surfaces the gap and waits. You provide the specific information — clock speed, device variant, peripheral configuration — and the AI proceeds with correct values rather than approximated ones.<br />
<br />
<br />
In practice the clarification request looks like this. You ask the AI to write a Timer2 ISR. Without the clarification instruction it assumes a clock speed, calculates a PR2 value, and produces code. With the clarification instruction it responds:<br />
<br />
<br />
<i>&quot;Before I write this I need to confirm: what is the target device, what clock speed is it running at, and what tick rate do you want for the ISR?&quot;</i><br />
<br />
<br />
You answer those questions and the AI produces code with correct values rather than plausible guesses.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Where to Put It in Each Tool</font></b><br />
<br />
<br />
<b>Claude</b><br />
<br />
<br />
Settings (bottom left) &gt; Profile &gt; paste into the &quot;What would you like Claude to know about you?&quot; field. This applies to all conversations. For device-specific additions, use the workspace instruction in your PBP3 workspace (Tutorial 02 covers this).<br />
<br />
<br />
<b>ChatGPT</b><br />
<br />
<br />
Settings (bottom left) &gt; Personalisation &gt; Custom Instructions. There are two fields. Put your identity and background in the first field (&quot;What should ChatGPT know about you?&quot;). Put the behavioural instructions — scope, existing code, clarification requirement, code quality — in the second field (&quot;How should ChatGPT respond?&quot;).<br />
<br />
<br />
<b>GitHub Copilot</b><br />
<br />
<br />
Create a file at <i>.github/copilot-instructions.md</i> in your repository root. Paste the prompt content as plain markdown. Copilot reads this file and applies the instructions to all suggestions and chat responses within that repository.<br />
<br />
<br />
<b>Warp</b><br />
<br />
<br />
Warp AI settings vary by version. Look for AI preferences or custom prompt settings in the Warp settings panel. The prompt content is the same — only the location changes.<br />
<br />
<br />
<b>Any API-based tool</b><br />
<br />
<br />
Pass the prompt content as the system parameter in your API call. The format is tool-dependent but the content is identical.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Testing Your System Prompt</font></b><br />
<br />
<br />
After setting up the prompt, test it with a deliberately ambiguous request before using it on real work. Something like:<br />
<br />
<br />
<i>&quot;Write me a Timer ISR for my PIC project.&quot;</i><br />
<br />
<br />
A correctly configured AI should respond by asking for the device, the clock speed, and the required tick rate before writing anything. If it proceeds without asking, the clarification requirement is not working and the prompt needs adjustment.<br />
<br />
<br />
Also test scope control:<br />
<br />
<br />
<i>&quot;Add a 50ms startup delay to this code.&quot;</i> <i>(paste a complete PBP3 program)</i><br />
<br />
<br />
The AI should add the delay and return the modified code with only that change annotated. If it restructures other sections, renames variables, or adds anything unrequested, the scope instruction needs strengthening.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What This Prompt Does Not Cover</font></b><br />
<br />
<br />
This prompt addresses behaviour. It does not address knowledge. An AI following these instructions perfectly will still produce incorrect register values, wrong DEFINE syntax, or invalid CONFIG bits if it does not have the right reference material. That is the problem addressed in Tutorials 02 and 05 — providing the compiler manual, device datasheet, and working examples as workspace documents.<br />
<br />
<br />
The system prompt and the workspace documents work together. The prompt controls how the AI behaves. The documents give it the knowledge to behave correctly.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Community Contributions</font></b><br />
<br />
<br />
If you develop additions to this prompt that work reliably for specific devices, peripherals, or use cases — please share them in a reply. Particularly useful additions would be:<br />
<br />
<ul><li>Device-family-specific instruction blocks that prevent known AI failure modes</li>
<li>Peripheral-specific clarification triggers — instructions that force the AI to ask for the right information before writing timer, UART, or ISR code</li>
<li>Additions that work well with specific tools where the generic prompt underperforms</li>
</ul><br />
<br />
<hr /><br />
<br />
<br />
<i>Part of the AI and PicBasic Pro Tutorial Series.</i><br />
<i>This tutorial was produced with AI</i><br />
<i>The system prompt provided is a starting point. Test it, adapt it, and do not use placeholder values in production. All AI-generated code must be reviewed and hardware tested before use.</i></div>

]]></content:encoded>
			<category domain="https://www.picbasic.co.uk/forum/forumdisplay.php/51-AI-Tutorials-and-Guides">AI Tutorials and Guides</category>
			<dc:creator>AI</dc:creator>
			<guid isPermaLink="true">https://www.picbasic.co.uk/forum/showthread.php/27129-Tutorial-07-—-System-Prompts-for-Embedded-Development-Getting-Reliable-Behaviour-Fro</guid>
		</item>
		<item>
			<title>Tutorial 06 — Putting It All Together</title>
			<link>https://www.picbasic.co.uk/forum/showthread.php/27127-Tutorial-06-—-Putting-It-All-Together?goto=newpost</link>
			<pubDate>Thu, 28 May 2026 07:40:02 GMT</pubDate>
			<description>*Tutorial 06 — Putting It All Together* 
AI and PicBasic Pro Tutorial Series — Post 6 of 6 
Content produced with AI assistance and reviewed by the...</description>
			<content:encoded><![CDATA[<div><b><font size="5">Tutorial 06 — Putting It All Together</font></b><br />
<i>AI and PicBasic Pro Tutorial Series — Post 6 of 6</i><br />
<i>Content produced with AI assistance and reviewed by the forum administrator.</i><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What You Have Built</font></b><br />
<br />
<br />
If you have followed the series from Tutorial 01, you now have three layers working together to make AI assistance with PBP3 reliable and repeatable.<br />
<br />
<br />
<b>Layer 1 — Profile Instruction</b><br />
Set once in your AI account settings. Applies to every conversation. Establishes baseline behaviour: complete code, explicit calculations, annotated changes, backup before modification, audit before fix.<br />
<br />
<br />
<b>Layer 2 — Workspace</b><br />
A named workspace for PBP3 development. Contains the compiler manual, your device datasheet, a targeted register reference, and working code samples. The workspace instruction tells the AI to use these documents as authority rather than relying on memory.<br />
<br />
<br />
<b>Layer 3 — Structured Workflow</b><br />
The three-prompt sequence that forces the AI to understand before it audits, and audit before it fixes. Used when debugging or reviewing code.<br />
<br />
<br />
Each layer adds precision. The profile sets general behaviour. The workspace adds device and compiler context. The workflow structures the reasoning process for any given task.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">A Typical Session — What It Looks Like in Practice</font></b><br />
<br />
<br />
You have a PBP3 source file that compiles with errors or behaves unexpectedly on hardware. Here is the sequence:<br />
<br />
<ol class="decimal"><li>Open a new conversation in your PBP3 workspace</li>
<li>Send Prompt 1 with your code — the AI explains what the code does</li>
<li>Send Prompt 2 with the code block from step 2 — the AI produces a numbered fault list</li>
<li>Review the fault list — you can correct it if anything is wrong before proceeding</li>
<li>Send Prompt 3 with the fault list and code — the AI produces annotated corrected code</li>
<li>Review the corrected code — compare changes against the fault list</li>
<li>Compile and test — if errors remain, paste compiler output into a follow-up</li>
<li>Test on hardware — compile-clean is not the same as hardware-correct</li>
</ol><br />
<br />
The key discipline throughout is that you stay in the loop. You review the fault list before fixes are applied. You review the corrected code before compiling. You test on hardware before trusting the output.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What This Approach Does and Does Not Do</font></b><br />
<br />
<br />
<b>What it does:</b><br />
<br />
<ul><li>Reduces the class of errors caused by the AI not having the right reference material</li>
<li>Structures the AI's reasoning so it cannot skip from &quot;code exists&quot; to &quot;fixed code&quot; without an intermediate audit</li>
<li>Ensures every change is annotated so you can understand what moved and why</li>
<li>Preserves your original code in every response so you never lose a working version</li>
<li>Produces compile-clean code more consistently than an unstructured single-prompt approach</li>
</ul><br />
<br />
<b>What it does not do:</b><br />
<br />
<ul><li>Guarantee correct hardware behaviour — a clean compile is not a working device</li>
<li>Replace your knowledge of the device — the AI can still make logical errors</li>
<li>Remove the need for hardware testing — that step is irreplaceable</li>
<li>Work perfectly first time on every project — it improves output quality, it does not make AI infallible</li>
</ul><br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Building on the Foundation</font></b><br />
<br />
<br />
The workspace and workflow described in this series are a starting point. Over time you will find things that work better for your specific devices, projects, and coding style. Some suggestions for expanding the approach:<br />
<br />
<br />
<b>Add more working examples to your workspace</b><br />
Every hardware-verified example you add gives the AI a better calibration baseline. Over time the workspace accumulates a body of known-good code that the AI can reference when generating new examples.<br />
<br />
<br />
<b>Expand your device reference document</b><br />
As you work with a device and discover its quirks, add them to your reference document. Notes on peripheral interactions, common configuration patterns, known pitfalls — these improve every future conversation.<br />
<br />
<br />
<b>Create separate workspaces for different device families</b><br />
A workspace optimised for mid-range 16F devices should not be mixed with 18F work. The CONFIG syntax, memory banking model, and peripheral architecture are different enough that keeping them separate prevents cross-contamination errors.<br />
<br />
<br />
<b>Refine your profile instruction</b><br />
When the AI does something that surprises you or produces output in a format you did not want, add a line to the profile instruction that covers it. The instruction improves with use.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Contributing to This Forum</font></b><br />
<br />
<br />
This tutorial series covers general principles. The community's collective experience — specific devices, specific peripherals, specific failure modes and how to prompt around them — is more valuable than any generic guide.<br />
<br />
<br />
If you develop a prompt template that works reliably for a specific device or peripheral, post it in the AI Prompts and Code Examples forum. If you find something in this tutorial series that is wrong, incomplete, or could be explained better, post a reply. This forum improves with contributions.<br />
<br />
<br />
When posting code examples, please follow the guidelines in the forum welcome post:<br />
<br />
<ul><li>Include the prompt that generated the code</li>
<li>State the target device and compiler version</li>
<li>State whether the code compiles</li>
<li>State whether it has been tested on hardware</li>
</ul><br />
<br />
The distinction between compile-tested and hardware-verified matters. Readers need to know which they are looking at.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Series Summary</font></b><br />
<br />
<ol class="decimal"><li><b>Tutorial 01</b> — Why AI gets PBP3 wrong and what causes it</li>
<li><b>Tutorial 02</b> — Setting up a workspace with the right reference documents</li>
<li><b>Tutorial 03</b> — Writing a profile instruction for consistent behaviour</li>
<li><b>Tutorial 04</b> — A structured three-prompt debugging workflow</li>
<li><b>Tutorial 05</b> — Working efficiently with complex documents</li>
<li><b>Tutorial 06</b> — Putting it all together (this post)</li>
</ol><br />
<br />
<hr /><br />
<br />
<br />
<i>Previous: Tutorial 05 — Working With Complex Documents</i><br />
<i>This tutorial series was produced with AI</i><br />
<i>The prompts and instructions in this series are starting points. Adapt them to your device and workflow before use. Hardware test all AI-generated code.</i></div>

]]></content:encoded>
			<category domain="https://www.picbasic.co.uk/forum/forumdisplay.php/51-AI-Tutorials-and-Guides">AI Tutorials and Guides</category>
			<dc:creator>AI</dc:creator>
			<guid isPermaLink="true">https://www.picbasic.co.uk/forum/showthread.php/27127-Tutorial-06-—-Putting-It-All-Together</guid>
		</item>
		<item>
			<title>Tutorial 05 — Working With Complex Documents: Datasheets and Manuals</title>
			<link>https://www.picbasic.co.uk/forum/showthread.php/27126-Tutorial-05-—-Working-With-Complex-Documents-Datasheets-and-Manuals?goto=newpost</link>
			<pubDate>Thu, 28 May 2026 07:37:54 GMT</pubDate>
			<description>*Tutorial 05 — Working With Complex Documents: Datasheets and Manuals* 
AI and PicBasic Pro Tutorial Series — Post 5 of 6 
Content produced with AI...</description>
			<content:encoded><![CDATA[<div><b><font size="5">Tutorial 05 — Working With Complex Documents: Datasheets and Manuals</font></b><br />
<i>AI and PicBasic Pro Tutorial Series — Post 5 of 6</i><br />
<i>Content produced with AI assistance and reviewed by the forum administrator.</i><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">How AI Reads a Document — Not the Way You Do</font></b><br />
<br />
<br />
When you open a 400-page datasheet you navigate it the way an experienced engineer does — straight to the oscillator section when configuring the PLL, straight to the CONFIG register table when a bit is behaving unexpectedly. Reading it end to end would take a day and retain very little.<br />
<br />
<br />
When you upload that same document to an AI workspace, the AI does not read it sequentially. It has access to the full text and can locate and cross-reference specific sections in response to a query — without fatigue, without losing context, and without the sequential constraint that makes large technical documents laborious for humans.<br />
<br />
<br />
This means the argument for simplifying a document before giving it to the AI — to make it more digestible — does not apply. The AI does not need it simplified. What it does need is for the right content to be present and findable.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Real Constraint — Context Window Size</font></b><br />
<br />
<br />
Every AI conversation has a context window — a limit on how much information can be active at once. When the AI is working on your code, that window contains your code, the conversation history, the workspace instruction, and content retrieved from your documents. Everything competes for the same space.<br />
<br />
<br />
A complete microcontroller datasheet converted to text can run to tens of thousands of lines. When the AI retrieves content from it, it pulls chunks into the active context. If those chunks contain electrical characteristics tables, package diagrams, and programming specifications that have nothing to do with writing PBP3 code, that space is wasted.<br />
<br />
<br />
A targeted extract covering only the sections relevant to PBP3 development uses that context space efficiently. Every line it occupies is earning its place.<br />
<br />
<br />
<b>Recommended approach: keep the full datasheet in the workspace for edge cases, and add a targeted extract as the primary reference the AI reaches for first.</b><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What to Extract From a PIC Datasheet</font></b><br />
<br />
<br />
The following sections cover the majority of questions that arise in PBP3 development. They apply to most PIC devices — the specific register names will vary but the categories are consistent:<br />
<br />
<ul><li><b>Configuration registers</b> — CONFIG word bit definitions, all words. Every project starts here and CONFIG errors are the most common AI-generated fault category.</li>
<li><b>Oscillator section</b> — OSCCON register, any software PLL control bits, the relationship between configuration bits and runtime oscillator control. Timing errors trace back here.</li>
<li><b>Weak pull-up control</b> — OPTION_REG or equivalent, individual port pull-up registers. Floating input faults trace back here.</li>
<li><b>Timer registers</b> — whichever timers your project uses, including the period calculation formula. Essential for ISR timing verification.</li>
<li><b>Interrupt control registers</b> — INTCON, PIE, PIR for relevant peripherals. The AI needs these to verify ISR enable sequences and flag-clear logic.</li>
<li><b>Port registers</b> — TRIS, PORT, LAT, ANSEL for each port. Pin direction, analog/digital selection, output latches.</li>
<li><b>Any shared-pin peripherals</b> — LCD controller pins, CCP pins, PPS if the device supports it. These interactions cause silent failures that are hard to trace without the datasheet.</li>
</ul><br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Asking the AI to Do the Extraction</font></b><br />
<br />
<br />
You do not need to do this manually. The AI can extract the relevant sections from a datasheet and produce a clean structured text document ready to upload to your workspace. Do this in a standard conversation outside your project — you want a clean context for this task.<br />
<br />
<br />
Upload the datasheet PDF and send a prompt similar to this:<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">; ============================================================<br />
; DATASHEET EXTRACTION PROMPT — TEMPLATE<br />
; Replace [YOUR DEVICE] with your device part number<br />
; Adjust the section list to match your device's register names<br />
; ============================================================<br />
<br />
<br />
I am setting up an AI workspace for PicBasic Pro 3 development<br />
targeting [YOUR DEVICE].<br />
<br />
<br />
Extract the following sections from the attached datasheet and<br />
produce a single clean structured text document I can upload to<br />
my workspace as a reference file.<br />
<br />
<br />
Extract these sections completely, preserving all register bit<br />
definitions, bit names, valid values, and any notes or warnings:<br />
<br />
<br />
1. All Configuration Word register definitions (all CONFIG words)<br />
2. OSCCON register and any software PLL/oscillator control bits<br />
3. Oscillator modes section — clock sources, PLL operation<br />
4. OPTION_REG or equivalent — complete bit definitions<br />
5. Weak pull-up registers for all ports<br />
6. Timer registers used in your projects — T2CON, PR2, etc<br />
7. Interrupt control registers — INTCON, PIE1, PIR1<br />
8. TRIS, PORT, LAT, ANSEL registers for all ports<br />
9. Any peripheral registers that share pins with general I/O<br />
<br />
<br />
Format the output as:<br />
- A clear heading for each register or section<br />
- Register address where available<br />
- Each bit listed with: number, name, description, valid values<br />
- Notes and cross-references from the datasheet preserved<br />
- No summaries or editorial comment — extracted content only<br />
<br />
<br />
Output the complete document inside:<br />
<br />
<br />
===REGISTER REFERENCE START===<br />
(content here)<br />
===REGISTER REFERENCE END===</code><hr />
</div><br />
<font color="#CC0000"><b>NOTE: This is a template prompt. Before using it, replace [YOUR DEVICE] with your actual device part number and adjust the section list to match the register names in your specific datasheet. Verify the extracted content against the datasheet before uploading it to your workspace.</b></font><br />
<br />
<br />
Copy the content between the markers, save it as a plain text file with a clear name such as <i>YourDevice_Register_Reference.txt</i>, and upload it to your workspace.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Verifying the Extract</font></b><br />
<br />
<br />
Before uploading, spot-check the extracted document against the datasheet on two or three registers you know well. Look for:<br />
<br />
<ul><li>Bit names that match exactly — not approximations of the name from the datasheet</li>
<li>Bit polarity described correctly — some enable bits are active low, some active high, and the AI can get this wrong</li>
<li>Any interactions between registers noted — for example, a global enable bit that must be cleared before individual bits take effect</li>
<li>All CONFIG words present and complete</li>
</ul><br />
<br />
If anything is missing, add a follow-up in the same conversation asking the AI to re-extract that specific section. Paste the correction into your file before uploading.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The PBP3 Manual</font></b><br />
<br />
<br />
The PBP3 manual is equally important and requires no extraction — upload the full manual PDF directly. It is not as large as a datasheet and its content is uniformly relevant to PBP3 development. The AI benefits from having the complete manual rather than a subset.<br />
<br />
<br />
The manual is available from the melabs website at <a href="https://www.melabs.com" target="_blank">https://www.melabs.com</a>.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Complete Document Stack</font></b><br />
<br />
<br />
A well-equipped workspace contains:<br />
<br />
<ol class="decimal"><li><b>Workspace instruction</b> — tells the AI to use documents as authority, not memory</li>
<li><b>PBP3 manual PDF</b> — complete language and compiler reference</li>
<li><b>Device register reference TXT</b> — targeted extract, primary reference for register queries</li>
<li><b>Full device datasheet PDF</b> — complete reference for edge cases</li>
<li><b>Working code samples</b> — style baseline for the target device</li>
</ol><br />
<br />
Each document earns its place. Together they give the AI a working reference for PBP3 development on your target device that is grounded in authoritative sources.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<i>Previous: Tutorial 04 — A Structured Three-Prompt Debugging Workflow</i><br />
<i>Next: Tutorial 06 — Putting It All Together</i><br />
<i>This tutorial series was produced with AI</i></div>

]]></content:encoded>
			<category domain="https://www.picbasic.co.uk/forum/forumdisplay.php/51-AI-Tutorials-and-Guides">AI Tutorials and Guides</category>
			<dc:creator>AI</dc:creator>
			<guid isPermaLink="true">https://www.picbasic.co.uk/forum/showthread.php/27126-Tutorial-05-—-Working-With-Complex-Documents-Datasheets-and-Manuals</guid>
		</item>
		<item>
			<title>Tutorial 04 — A Structured Three-Prompt Debugging Workflow</title>
			<link>https://www.picbasic.co.uk/forum/showthread.php/27125-Tutorial-04-—-A-Structured-Three-Prompt-Debugging-Workflow?goto=newpost</link>
			<pubDate>Thu, 28 May 2026 07:36:52 GMT</pubDate>
			<description>*Tutorial 04 — A Structured Three-Prompt Debugging Workflow* 
AI and PicBasic Pro Tutorial Series — Post 4 of 6 
Content produced with AI assistance...</description>
			<content:encoded><![CDATA[<div><b><font size="5">Tutorial 04 — A Structured Three-Prompt Debugging Workflow</font></b><br />
<i>AI and PicBasic Pro Tutorial Series — Post 4 of 6</i><br />
<i>Content produced with AI assistance and reviewed by the forum administrator.</i><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Why One Prompt Is Not Enough</font></b><br />
<br />
<br />
The instinct when debugging code with AI is to paste the code and ask it to fix the problems. Sometimes this works. More often the AI pattern-matches on symptoms, misses underlying causes, and produces a corrected version it cannot fully justify — because it went straight to fixing without properly understanding what it was looking at.<br />
<br />
<br />
The structured workflow below forces a different sequence. The AI must understand the code before it audits it, and audit it before it touches it. Each step produces a clearly marked output block that feeds directly into the next prompt. You do not summarise or paraphrase between steps — you paste the raw output. This keeps the AI working from its own verified reasoning rather than reconstructing from memory at each stage.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Three-Step Sequence</font></b><br />
<br />
<br />
<b>Step 1 — Understand</b><br />
The AI explains what the code does and how it works. This forces it to build an accurate model of the code before forming any opinions about what is wrong with it.<br />
<br />
<br />
<b>Step 2 — Audit</b><br />
The AI checks the code against a specific list of known fault categories and produces a numbered fault list. It does not make any changes at this stage.<br />
<br />
<br />
<b>Step 3 — Fix</b><br />
The AI receives the fault list and the original code together and produces a corrected version with every change annotated and justified.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">How Chaining Works</font></b><br />
<br />
<br />
Each prompt ends with an instruction to output results in a clearly delimited block. You copy that block exactly — including the markers — and paste it at the top of the next prompt before the new instructions. The AI works from its own prior output rather than starting fresh.<br />
<br />
<br />
Never paraphrase or summarise between steps. Copy the raw output block.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Prompt 1 — Understand the Code</font></b><br />
<br />
<br />
Paste your source code after this prompt, then send it. Adjust the description to match what your code actually does.<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">; ============================================================<br />
; PROMPT 1 — UNDERSTAND<br />
; Adjust the description to match your code before use<br />
; ============================================================<br />
<br />
<br />
You are an embedded systems engineer with knowledge of PicBasic Pro 3<br />
(PBP3) by melabs and PIC architecture. Analyse the code below and<br />
explain: the overall purpose of the program; what the port and register<br />
configuration implies about the hardware; any conditional compilation<br />
guards and what they do; the main logic flow and how it works.<br />
<br />
<br />
Reference the workspace documents where relevant. Write for someone<br />
who understands embedded systems but has not seen this code before.<br />
<br />
<br />
At the end, output the original source code unchanged inside:<br />
<br />
<br />
===ORIGINAL CODE START===<br />
(code here)<br />
===ORIGINAL CODE END===</code><hr />
</div><br />
<font color="#0066CC"><b>Before moving to Prompt 2:</b></font> copy everything between and including the ===ORIGINAL CODE START=== and ===ORIGINAL CODE END=== markers and paste it at the top of Prompt 2.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Prompt 2 — Audit the Code</font></b><br />
<br />
<br />
Paste the original code block from Prompt 1 at the top. Adjust the device and clock references for your target.<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">===ORIGINAL CODE START===<br />
(paste Prompt 1 code block here)<br />
===ORIGINAL CODE END===<br />
<br />
<br />
; ============================================================<br />
; PROMPT 2 — AUDIT<br />
; Replace [YOUR DEVICE] and [YOUR CLOCK] before use<br />
; ============================================================<br />
<br />
<br />
Audit the source code above for [YOUR DEVICE] at [YOUR CLOCK] MHz.<br />
Use the workspace documents as your reference. Do not make any changes.<br />
<br />
<br />
Check the following specifically:<br />
<br />
<br />
1. CONFIG blocks — count them, identify any conflicting bits, confirm<br />
&nbsp;  settings are correct for the target device and clock speed.<br />
<br />
<br />
2. DEFINE OSC — confirm correct value and placement. It must appear<br />
&nbsp;  before any timing-dependent code.<br />
<br />
<br />
3. Register widths — check every literal assigned to an 8-bit register<br />
&nbsp;  and flag any that exceed 8 bits.<br />
<br />
<br />
4. Floating inputs — list every pin configured as input with no<br />
&nbsp;  pull-up enabled and no reference in the code.<br />
<br />
<br />
5. Timing — verify any PAUSE or PAUSEUS values and any timer period<br />
&nbsp;  calculations against the declared clock speed.<br />
<br />
<br />
6. ISR logic — if the code contains interrupt service routines,<br />
&nbsp;  trace the branch logic step by step. Confirm STATUS flag values<br />
&nbsp;  at each branch point and whether the branch instruction is correct.<br />
<br />
<br />
For each fault state: location, what is wrong, why it is wrong.<br />
<br />
<br />
===FAULT LIST START===<br />
FAULT 1: [location] | [what is wrong] | [why it is wrong]<br />
FAULT 2: [location] | [what is wrong] | [why it is wrong]<br />
===FAULT LIST END===<br />
<br />
<br />
Then output the original code unchanged:<br />
<br />
<br />
===ORIGINAL CODE START===<br />
(code here)<br />
===ORIGINAL CODE END===</code><hr />
</div><br />
<font color="#0066CC"><b>Before moving to Prompt 3:</b></font> copy the entire ===FAULT LIST START=== block and the entire ===ORIGINAL CODE START=== block and paste both into Prompt 3.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Prompt 3 — Fix and Verify</font></b><br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">===FAULT LIST START===<br />
(paste fault list from Prompt 2 here)<br />
===FAULT LIST END===<br />
<br />
<br />
===ORIGINAL CODE START===<br />
(paste code block from Prompt 2 here)<br />
===ORIGINAL CODE END===<br />
<br />
<br />
; ============================================================<br />
; PROMPT 3 — FIX<br />
; Replace [YOUR DEVICE] and [YOUR CLOCK] before use<br />
; ============================================================<br />
<br />
<br />
Fix every fault in the fault list. Use the workspace documents as<br />
your reference for all syntax, DEFINE values, and CONFIG bits.<br />
<br />
<br />
Requirements:<br />
- Produce a single clean CONFIG block. Remove any duplicate.<br />
- DEFINE OSC must appear before any timing-dependent code.<br />
- Correct any oversized register literals.<br />
- Resolve floating inputs — justify the approach against circuit intent.<br />
- Verify all timer calculations and PAUSE values against clock speed.<br />
- Preserve all existing functionality exactly.<br />
<br />
<br />
Mark every change in the code: ; FIX [n]: description<br />
<br />
<br />
===FIX SUMMARY START===<br />
FIX 1: [what was wrong] | [what was changed] | [why]<br />
===FIX SUMMARY END===<br />
<br />
<br />
===CORRECTED CODE START===<br />
(corrected code here)<br />
===CORRECTED CODE END===</code><hr />
</div><br />
<hr /><br />
<br />
<br />
<b><font size="4">If the Code Still Will Not Compile</font></b><br />
<br />
<br />
Paste the full compiler error output and the corrected code block from Prompt 3 into a follow-up message in the same conversation:<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">; ============================================================<br />
; COMPILER ERROR FOLLOW-UP<br />
; ============================================================<br />
<br />
<br />
The corrected code above produced the following compiler errors.<br />
Identify the cause of each error by reference to the workspace<br />
documents and produce a corrected version.<br />
<br />
<br />
COMPILER OUTPUT:<br />
(paste full compiler output here — do not paraphrase it)<br />
<br />
<br />
===CORRECTED CODE START===<br />
(paste code from Prompt 3 here)<br />
===CORRECTED CODE END===</code><hr />
</div><br />
Paste the raw compiler output — do not describe it in your own words. The error messages give the AI precise location and fault information that a description loses.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Important Notes</font></b><br />
<br />
<br />
<font color="#CC0000"><b>The prompts above are templates. Before using them:</b></font><br />
<br />
<ul><li>Replace [YOUR DEVICE] with your actual target PIC part number</li>
<li>Replace [YOUR CLOCK] with your actual clock speed in MHz</li>
<li>Adjust the Prompt 1 description to match what your code actually does</li>
<li>The audit checklist in Prompt 2 covers the most common fault categories — add device-specific checks if you know your device has particular quirks</li>
</ul><br />
<br />
The corrected code the AI produces must still be tested. A compile-clean result is not the same as correct behaviour on hardware. The workflow removes a significant class of errors before the code reaches you — it does not replace hardware testing.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<i>Previous: Tutorial 03 — Setting a Profile Instruction</i><br />
<i>Next: Tutorial 05 — Working With Complex Documents</i><br />
<i>This tutorial series was produced with AI</i></div>

]]></content:encoded>
			<category domain="https://www.picbasic.co.uk/forum/forumdisplay.php/51-AI-Tutorials-and-Guides">AI Tutorials and Guides</category>
			<dc:creator>AI</dc:creator>
			<guid isPermaLink="true">https://www.picbasic.co.uk/forum/showthread.php/27125-Tutorial-04-—-A-Structured-Three-Prompt-Debugging-Workflow</guid>
		</item>
		<item>
			<title>Tutorial 03 — Writing a Profile Instruction for Consistent Behaviour</title>
			<link>https://www.picbasic.co.uk/forum/showthread.php/27124-Tutorial-03-—-Writing-a-Profile-Instruction-for-Consistent-Behaviour?goto=newpost</link>
			<pubDate>Thu, 28 May 2026 07:35:47 GMT</pubDate>
			<description>*Tutorial 03 — Writing a Profile Instruction for Consistent Behaviour* 
AI and PicBasic Pro Tutorial Series — Post 3 of 6 
Content produced with AI...</description>
			<content:encoded><![CDATA[<div><b><font size="5">Tutorial 03 — Writing a Profile Instruction for Consistent Behaviour</font></b><br />
<i>AI and PicBasic Pro Tutorial Series — Post 3 of 6</i><br />
<i>Content produced with AI assistance and reviewed by the forum administrator.</i><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What is a Profile Instruction?</font></b><br />
<br />
<br />
Most AI tools have two levels of persistent instruction. The workspace instruction (covered in Tutorial 02) applies to a specific workspace. A profile instruction sits above that — it applies to every conversation you have, across all workspaces and standard chats.<br />
<br />
<br />
Think of the profile instruction as telling the AI who you are and how you work, once, permanently. The workspace instruction then adds the specific device and compiler context on top of that foundation.<br />
<br />
<br />
In Claude this is found under Settings then Profile. Other AI tools have equivalent features under different names — user preferences, custom instructions, personal context, or similar.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Why This Matters for PBP3 Work</font></b><br />
<br />
<br />
Without a profile instruction the AI treats every conversation as a generic interaction. It produces code that looks professional but may be incomplete, hedges its answers with unnecessary caveats, and does not flag uncertainty about specific syntax or register values clearly.<br />
<br />
<br />
With a well-written profile instruction the AI knows:<br />
<br />
<ul><li>You are an embedded systems developer, not a beginner</li>
<li>Code must be complete and compilable — no skeleton placeholders</li>
<li>Timing calculations must be shown explicitly so you can verify them</li>
<li>Every change to existing code must be annotated</li>
<li>Your original code must be preserved before any modifications are made</li>
<li>Uncertainty must be stated clearly, once, and then the AI moves on</li>
</ul><br />
<br />
These are not things you want to repeat in every conversation. Set them once in the profile and they apply everywhere.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">A Starting Profile Instruction</font></b><br />
<br />
<br />
The following is a starting point. It is written for PBP3 development but applies sensibly to general embedded work. Adapt it to your own working style — add things that matter to you, remove things that do not.<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">; ============================================================<br />
; PROFILE INSTRUCTION — STARTING POINT, ADAPT TO YOUR NEEDS<br />
; ============================================================<br />
<br />
<br />
I am an embedded systems developer working in PicBasic Pro 3 (PBP3)<br />
by melabs, targeting PIC microcontrollers across the mid-range and<br />
enhanced families.<br />
<br />
<br />
GENERAL BEHAVIOUR<br />
Lead with the answer. No preamble. If my approach has a problem, say<br />
so before building on it. Flag uncertainty once, clearly, then move on.<br />
Do not invent syntax or parameters — if uncertain, say so.<br />
<br />
<br />
CODE QUALITY<br />
Every piece of code must be complete and compilable. No skeleton<br />
placeholders unless I ask for an outline. Show timing calculations<br />
explicitly so I can verify them. Trace logic before presenting code.<br />
<br />
<br />
BEFORE WRITING ANY CODE<br />
Confirm: target device is identified; DEFINE OSC matches hardware<br />
clock including PLL; DEFINE statements are valid for the device;<br />
register names and bit positions are correct. If any cannot be<br />
confirmed, ask before proceeding.<br />
<br />
<br />
CHANGES AND MODIFICATIONS<br />
Show what changes and why. Mark every change: ; MOD: description<br />
Never silently remove code. Flag side effects before making changes.<br />
<br />
<br />
BACKUPS<br />
Before modifying any code I provide, output the original unchanged:<br />
<br />
<br />
===ORIGINAL BACKUP START===<br />
(original code here)<br />
===ORIGINAL BACKUP END===<br />
<br />
<br />
Then the modified version:<br />
<br />
<br />
===MODIFIED CODE START===<br />
(modified code here)<br />
===MODIFIED CODE END===<br />
<br />
<br />
FAULT FINDING<br />
Identify faults before fixing them. Present as a numbered list:<br />
location, what is wrong, why it is wrong. Do not mix audit and fix<br />
in the same response unless I ask.<br />
<br />
<br />
CALCULATIONS<br />
Show all timing calculations in full with formula and values.<br />
Flag approximate results and state the margin.</code><hr />
</div><br />
<font color="#CC0000"><b>NOTE: This is an example profile instruction. It is provided as a starting point only. Adapt it to your specific needs and working style before use. Do not treat this as tested or authoritative — adjust based on your own experience.</b></font><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">How the Two Levels Work Together</font></b><br />
<br />
<br />
The profile instruction sets baseline behaviour for all AI interactions. The workspace instruction adds device and compiler-specific context for PBP3 work. They do not conflict — the workspace instruction sits on top of the profile and adds specificity without overriding the general behaviour.<br />
<br />
<br />
A conversation inside your PBP3 workspace therefore starts with:<br />
<br />
<ol class="decimal"><li>Profile — general behaviour, code quality standards, backup discipline</li>
<li>Workspace instruction — device family, compiler, document authority</li>
<li>Workspace documents — manual, datasheet, working examples</li>
</ol><br />
<br />
Each layer adds precision. Together they produce an AI interaction that is grounded in the right documents, behaves consistently, and meets a clear quality standard for every response.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">This is a Starting Point</font></b><br />
<br />
<br />
The profile instruction above will not be perfect for your workflow on day one. Use it, notice where the AI does something you did not expect, and add a line that covers it. Over time it becomes an accurate description of how you work and the AI's output becomes correspondingly more predictable.<br />
<br />
<br />
One clear instruction per behaviour you want to change. Keep it concise. The profile instruction is a living document — treat it as one.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<i>Previous: Tutorial 02 — Setting Up Your AI Workspace</i><br />
<i>Next: Tutorial 04 — A Structured Three-Prompt Debugging Workflow</i><br />
<i>This tutorial series was produced with AI</i></div>

]]></content:encoded>
			<category domain="https://www.picbasic.co.uk/forum/forumdisplay.php/51-AI-Tutorials-and-Guides">AI Tutorials and Guides</category>
			<dc:creator>AI</dc:creator>
			<guid isPermaLink="true">https://www.picbasic.co.uk/forum/showthread.php/27124-Tutorial-03-—-Writing-a-Profile-Instruction-for-Consistent-Behaviour</guid>
		</item>
		<item>
			<title><![CDATA[Tutorial 02 — Setting Up Your AI Workspace[B][SIZE=5]Tutorial 02 — Setting Up Your AI]]></title>
			<link>https://www.picbasic.co.uk/forum/showthread.php/27123-Tutorial-02-—-Setting-Up-Your-AI-Workspace-B-SIZE-5-Tutorial-02-—-Setting-Up-Your-AI?goto=newpost</link>
			<pubDate>Thu, 28 May 2026 07:33:48 GMT</pubDate>
			<description>*Tutorial 02 — Setting Up Your AI Workspace* 
AI and PicBasic Pro Tutorial Series — Post 2 of 6 
Content produced with AI assistance and reviewed by...</description>
			<content:encoded><![CDATA[<div><b><font size="5">Tutorial 02 — Setting Up Your AI Workspace</font></b><br />
<i>AI and PicBasic Pro Tutorial Series — Post 2 of 6</i><br />
<i>Content produced with AI assistance and reviewed by the forum administrator.</i><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What is a Persistent Workspace?</font></b><br />
<br />
<br />
A standard AI conversation has no memory. Close it and start a new one and the AI knows nothing about your device, your project, or anything you discussed before. Every session starts from zero.<br />
<br />
<br />
A persistent workspace changes that. It is a named area within the AI tool where you can upload documents and write a permanent instruction. Every conversation you start inside that workspace automatically has access to those documents and that instruction — without you having to provide them again.<br />
<br />
<br />
For PBP3 development this matters because the documents that fix the AI's knowledge gap — the compiler manual, the device datasheet, working code examples — only need to be uploaded once. After that they are simply there for every conversation.<br />
<br />
<br />
Different AI tools call this feature different things. In Claude it is called a Project. Other tools use similar workspace, collection, or knowledge base concepts. The principle is the same regardless of the tool you are using.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Creating Your Workspace</font></b><br />
<br />
<br />
The exact steps vary by AI tool. In general:<br />
<br />
<ol class="decimal"><li>Look for a Projects, Workspaces, or Collections section in the navigation</li>
<li>Create a new one and give it a name that identifies the device family — for example <i>PBP3 Mid-Range Development</i> or <i>PBP3 18F Projects</i></li>
<li>You can create separate workspaces for different device families later</li>
</ol><br />
<br />
Give the workspace a name that tells you immediately which device family and compiler it covers. You may end up with several over time.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Workspace Instruction</font></b><br />
<br />
<br />
Most workspace features let you write a permanent instruction that the AI reads before every conversation. This is separate from the documents — it is a set of behavioural rules that apply throughout the workspace.<br />
<br />
<br />
Here is a starting instruction you can adapt. Replace the device name with your target device:<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">; ============================================================<br />
; WORKSPACE INSTRUCTION — ADAPT BEFORE USE<br />
; Replace [YOUR DEVICE] with your actual target PIC<br />
; Replace [YOUR CLOCK] with your actual clock speed<br />
; ============================================================<br />
<br />
<br />
You are an embedded systems engineer working in PicBasic Pro 3 (PBP3)<br />
by melabs, targeting [YOUR DEVICE] at [YOUR CLOCK] MHz.<br />
<br />
<br />
Before making any claim about PBP3 syntax, DEFINE statements, CONFIG<br />
bits, or peripheral register behaviour, consult the reference documents<br />
in this workspace. Do not rely on memory for device-specific details —<br />
the documents take priority.<br />
<br />
<br />
If you are uncertain about any DEFINE, CONFIG bit, or register<br />
interaction, say so before proceeding. Do not approximate.<br />
<br />
<br />
When reviewing or correcting code:<br />
- Preserve all existing functionality unless a fault requires otherwise<br />
- Mark every change with a comment: ; FIX [n]: description<br />
- Justify every fix by reference to the manual or device datasheet<br />
- Flag any assumption not supported by the documents</code><hr />
</div><br />
<font color="#CC0000"><b>NOTE: This is an example instruction. Adapt it to your device and requirements before use. The device name and clock speed placeholders must be replaced.</b></font><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Which Documents to Upload</font></b><br />
<br />
<br />
Upload these in order of importance. The first two are essential. The others add significant value but can be added later.<br />
<br />
<br />
<b>Document 1 — The PBP3 Compiler Manual (Essential)</b><br />
<br />
<br />
The PBP3 manual covers the full language: DEFINE statements, built-in functions, interrupt handling, inline assembly, and compiler directives. Without it the AI approximates PBP3 syntax from general knowledge. With it, syntax questions have a definitive reference.<br />
<br />
<br />
The manual is available free from the melabs website at <a href="https://www.melabs.com" target="_blank">https://www.melabs.com</a> in the support or downloads section.<br />
<br />
<br />
<b>Document 2 — Your Device Datasheet (Essential)</b><br />
<br />
<br />
The Microchip datasheet for your target device covers CONFIG registers, peripheral registers, oscillator modes, and pin functions. AI-generated CONFIG errors almost always trace back to not having this document.<br />
<br />
<br />
Datasheets are available free from <a href="https://www.microchip.com" target="_blank">https://www.microchip.com</a> — search for your device part number and download the datasheet PDF.<br />
<br />
<br />
<b>Document 3 — Working Code Samples (Strongly Recommended)</b><br />
<br />
<br />
Upload one or more PBP3 source files that compile and run correctly on your target device. These give the AI a calibration baseline — it can see what correct PBP3 for this device looks like before it touches your code. Without working samples the AI infers correct style from whatever code you give it, including broken code.<br />
<br />
<br />
<b>Document 4 — A Device Reference Summary (Recommended)</b><br />
<br />
<br />
A short plain text document listing the DEFINE statements, standard register values, and peripheral configurations you use regularly. Even a one-page summary covering your standard oscillator setup, timer configuration, and interrupt registers prevents a significant class of errors. You build this over time as you work with the device.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Document Order and Naming</font></b><br />
<br />
<br />
Name your documents clearly so the AI can identify them. A targeted register extract named <i>PIC16F_Register_Reference.txt</i> is more useful than a file called <i>document1.pdf</i>.<br />
<br />
<br />
Upload the targeted reference documents before the full datasheet. The AI will reach for the most specific relevant document first when the naming makes the purpose clear.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What You Have After This Step</font></b><br />
<br />
<br />
A workspace that opens every conversation with:<br />
<br />
<ul><li>The AI already knowing it is working in PBP3 on your specific device</li>
<li>The compiler manual available for syntax reference</li>
<li>The device datasheet available for CONFIG and register reference</li>
<li>Working code examples as a style baseline</li>
<li>Instructions to flag uncertainty rather than approximate</li>
</ul><br />
<br />
The setup takes approximately twenty minutes. After that it applies to every conversation in the workspace without any further effort.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<i>Previous: Tutorial 01 — Getting Started</i><br />
<i>Next: Tutorial 03 — Setting a Profile Instruction for Consistent Behaviour</i><br />
<i>This tutorial series was produced with AI</i></div>

]]></content:encoded>
			<category domain="https://www.picbasic.co.uk/forum/forumdisplay.php/51-AI-Tutorials-and-Guides">AI Tutorials and Guides</category>
			<dc:creator>AI</dc:creator>
			<guid isPermaLink="true">https://www.picbasic.co.uk/forum/showthread.php/27123-Tutorial-02-—-Setting-Up-Your-AI-Workspace-B-SIZE-5-Tutorial-02-—-Setting-Up-Your-AI</guid>
		</item>
		<item>
			<title>Tutorial 01 — Getting Started: Why AI Gets PBP3 Wrong and How to Fix That</title>
			<link>https://www.picbasic.co.uk/forum/showthread.php/27122-Tutorial-01-—-Getting-Started-Why-AI-Gets-PBP3-Wrong-and-How-to-Fix-That?goto=newpost</link>
			<pubDate>Thu, 28 May 2026 07:31:27 GMT</pubDate>
			<description>*Tutorial 01 — Getting Started: Why AI Gets PBP3 Wrong and How to Fix That* 
AI and PicBasic Pro Tutorial Series — Post 1 of 6 
Content produced with...</description>
			<content:encoded><![CDATA[<div><b><font size="5">Tutorial 01 — Getting Started: Why AI Gets PBP3 Wrong and How to Fix That</font></b><br />
<i>AI and PicBasic Pro Tutorial Series — Post 1 of 6</i><br />
<i>Content produced with AI assistance and reviewed by the forum administrator.</i><br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Problem</font></b><br />
<br />
<br />
If you have pasted PBP3 code into an AI tool and asked it to write, fix, or explain it, you have probably had mixed results. Sometimes it gets things right. Often it produces code that looks correct but will not compile, uses the wrong DEFINE values, or generates CONFIG bits that conflict with each other.<br />
<br />
<br />
This is not the AI being careless. It is the AI working without the information it needs.<br />
<br />
<br />
PicBasic Pro is a niche compiler. The amount of PBP3-specific content in any AI's training data is limited. When the AI does not have a reliable answer it approximates — and approximations on CONFIG bits, DEFINE statements, and register layouts produce code that looks plausible but fails on the compiler or the device.<br />
<br />
<br />
The good news is that this problem has a practical solution that does not require any special technical knowledge. You give the AI the reference documents it needs rather than relying on what it already knows.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Root Cause — What AI Actually Knows About PBP3</font></b><br />
<br />
<br />
AI tools are trained on large amounts of publicly available text. For mainstream languages like Python or C, that training data is extensive and the AI performs well. For PBP3, the training data is thin. The AI has general PIC knowledge, some familiarity with BASIC syntax, and fragments of PBP3 examples from forum posts and documentation that made it into training.<br />
<br />
<br />
What it does not have is a reliable, complete internal model of:<br />
<br />
<ul><li>PBP3 DEFINE statements and which values are valid for which devices</li>
<li>Device-specific CONFIG bit names and their correct settings</li>
<li>Register layouts and bit interactions for specific PIC variants</li>
<li>The difference in peripheral behaviour between 16F and 18F families</li>
<li>PBP3-specific compiler directives and their placement rules</li>
</ul><br />
<br />
When you ask the AI to generate or fix code and it hits one of these gaps, it fills it from general knowledge and adjacent information. The result is code that the AI is confident about and that is wrong in ways that are not immediately obvious.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">The Solution — Give the AI Its Reference Material</font></b><br />
<br />
<br />
The solution is straightforward. Instead of asking the AI to recall PBP3 specifics from training, you give it the documents it should be working from — the compiler manual, the device datasheet, and examples of working code. The AI then works from those documents rather than from memory.<br />
<br />
<br />
Modern AI tools support this through a feature called a persistent workspace or project. You upload documents once and every conversation you have within that workspace has access to them automatically. The AI does not need to be reminded. It does not lose the documents between sessions. They are simply there.<br />
<br />
<br />
This single change — moving from AI memory to AI plus authoritative documents — addresses the majority of errors that AI-generated PBP3 code contains.<br />
<br />
<br />
The following tutorials in this series cover the practical steps:<br />
<br />
<ol class="decimal"><li><b>Tutorial 02</b> — Setting up your AI workspace and uploading reference documents</li>
<li><b>Tutorial 03</b> — Writing a profile instruction that sets the AI's baseline behaviour</li>
<li><b>Tutorial 04</b> — A structured three-prompt workflow for debugging existing code</li>
<li><b>Tutorial 05</b> — How AI reads complex documents and how to make them work harder</li>
<li><b>Tutorial 06</b> — Putting it all together: a complete working setup</li>
</ol><br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What to Expect</font></b><br />
<br />
<br />
Following this series will not make AI produce perfect PBP3 code every time. That is not a realistic expectation. What it will do is significantly reduce the class of errors that come from the AI not having the right information. Configuration errors, wrong DEFINE values, invalid register references — these largely disappear when the AI has the manual and the datasheet in front of it.<br />
<br />
<br />
What remains is the AI's responsibility to reason correctly from that material. You still need to read the output. You still need to test on hardware. You are not removing your judgement from the process — you are removing the information gap that produces the most common and most frustrating class of errors.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<i>Next: Tutorial 02 — Setting Up Your AI Workspace</i><br />
<i>This tutorial series was produced with AI</i></div>

]]></content:encoded>
			<category domain="https://www.picbasic.co.uk/forum/forumdisplay.php/51-AI-Tutorials-and-Guides">AI Tutorials and Guides</category>
			<dc:creator>AI</dc:creator>
			<guid isPermaLink="true">https://www.picbasic.co.uk/forum/showthread.php/27122-Tutorial-01-—-Getting-Started-Why-AI-Gets-PBP3-Wrong-and-How-to-Fix-That</guid>
		</item>
		<item>
			<title>Welcome to the AI Tutorials Forum — Read This First</title>
			<link>https://www.picbasic.co.uk/forum/showthread.php/27121-Welcome-to-the-AI-Tutorials-Forum-—-Read-This-First?goto=newpost</link>
			<pubDate>Thu, 28 May 2026 07:19:03 GMT</pubDate>
			<description>*Welcome to the AI Tutorials Forum — Read This First* 
 
 
 
 
 
This forum exists because the main AI and PICBASIC thread has grown to over 150...</description>
			<content:encoded><![CDATA[<div><b><font size="5">Welcome to the AI Tutorials Forum — Read This First</font></b><br />
<br />
<br />
<hr /><br />
<br />
<br />
This forum exists because the main AI and PICBASIC thread has grown to over 150 posts and nearly a million views. Clearly the community has an appetite for this topic. This area gives it a proper home.<br />
<br />
<br />
The purpose here is practical and specific. Not a debate about whether AI is useful — that conversation is happening elsewhere. This forum is for people who have decided to try it and want to do it well.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">What belongs here</font></b><br />
<br />
<ul><li>Step-by-step guides for using AI tools with PicBasic Pro</li>
<li>Prompt templates that produce reliable results</li>
<li>Code examples showing the prompt that generated them</li>
<li>Notes on what works and what does not for specific devices or peripherals</li>
<li>Corrections and improvements to existing posts</li>
</ul><br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">If you post a code example, please include</font></b><br />
<br />
<ol class="decimal"><li><b>The prompt</b> — exactly what you asked the AI</li>
<li><b>The target device</b> — which PIC</li>
<li><b>The compiler version</b> — PBP3 Gold, Silver, etc</li>
<li><b>Whether it compiles</b> — tested or untested</li>
<li><b>Whether it runs on hardware</b> — hardware verified or simulation only</li>
</ol><br />
<br />
That last point matters more than anything else. A compile-clean example and a hardware-verified example are not the same thing. Readers need to know which they are looking at.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<b><font size="4">Where to start</font></b><br />
<br />
<br />
If you are new to using AI with PBP3, the tutorials posted in this forum cover the setup and workflow from the beginning. Start with the Claude Project setup guide — it explains how to give the AI the reference documents it needs to produce reliable PBP3 code rather than plausible-looking approximations.<br />
<br />
<br />
If you already have a working approach and want to share it, post it. This forum improves with contributions.<br />
<br />
<br />
<hr /><br />
<br />
<br />
<i>Tutorials forum opened May 2026. Part of the AI and PICBASIC section.</i></div>

]]></content:encoded>
			<category domain="https://www.picbasic.co.uk/forum/forumdisplay.php/51-AI-Tutorials-and-Guides">AI Tutorials and Guides</category>
			<dc:creator>AI</dc:creator>
			<guid isPermaLink="true">https://www.picbasic.co.uk/forum/showthread.php/27121-Welcome-to-the-AI-Tutorials-Forum-—-Read-This-First</guid>
		</item>
		<item>
			<title>Transparancy</title>
			<link>https://www.picbasic.co.uk/forum/showthread.php/27120-Transparancy?goto=newpost</link>
			<pubDate>Thu, 28 May 2026 07:13:17 GMT</pubDate>
			<description>Some of The tutorials and guides in this forum are produced with the assistance of AI tools. Code examples are NOT reviewed by the forum...</description>
			<content:encoded><![CDATA[<div><i>Some of The tutorials and guides in this forum are produced with the assistance of AI tools. Code examples are NOT reviewed by the forum administrator before posting. Hardware-verified examples are marked as such. AI-generated content is presented as a starting point — not as a substitute for understanding your hardware.</i></div>

]]></content:encoded>
			<category domain="https://www.picbasic.co.uk/forum/forumdisplay.php/51-AI-Tutorials-and-Guides">AI Tutorials and Guides</category>
			<dc:creator>lester</dc:creator>
			<guid isPermaLink="true">https://www.picbasic.co.uk/forum/showthread.php/27120-Transparancy</guid>
		</item>
	</channel>
</rss>
